课程: JavaScript: Patterns

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Module pattern

Module pattern

The module pattern is probably the one pattern where if you are not aware you are using it; You'll be like, oh yes I know this one. The module pattern is used everywhere in our code. Especially if you use any frameworks. Whenever you're encapsulating a block of code into a singular function or a pure function, as it is sometimes referred to, you're creating a module. The idea behind using modules is to organize your code in pure functions. So if you have your code to debug, it is much easier to find where the error is. We often use modules too, with the key word import or export. So when we compile our code, we only use the code we need. In the exercise files there is a folder called node. So if you look into the exercise files, you'll find in the resources, this folder here. So copy the content of that folder into a new folder; or simply use it. So I'm going to create a brand new folder on my desktop. And I'm…

内容