Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2f6eef0

Browse files
module pattern
1 parent 807bfbe commit 2f6eef0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎05-object-creation.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,15 @@ Person.prototype = (function(){
110110
}
111111
}());
112112
```
113+
114+
## module pattern
115+
116+
* combination of above:
117+
1. define a namespace
118+
1. assign an immediate function to it
119+
1. which declares dependencies at the top
120+
1. has private methods
121+
1. and returns an object revealing public API of the module
122+
1. globals can be passed in parameters to the immediate function
123+
* a module can create a constructor as well
124+
* if you return the constructor function instead of an object

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /