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 00ba823

Browse files
static members, constants
1 parent ed557dd commit 00ba823

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

‎05-object-creation.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,21 @@ new SandBox('dependencies', 'here', function(box){
144144
* add required modules to ```this```
145145
* then call callback with ```this```
146146
* the callback is the users sandbox and get populated with the requested functionality
147+
148+
## static members
149+
150+
* just add property to constructor function - as that's an object as well
151+
* (normal methods are added to the prototype or the returned object)
152+
* you can't call static methods on instance unless you add an alias to prototype
153+
* when aliasing static method on prototype - careful if you use ```this``` within the method
154+
155+
## private static members
156+
157+
* return constructor function via an immediate (self invoking) function
158+
* variables within the immediate function are invisible outside (as usual)
159+
160+
## constants
161+
162+
* no real way to do it in ES5
163+
* just naming convention: all caps, and also worth making sure they're static
164+
* ```const``` keyword coming in ES6

0 commit comments

Comments
(0)

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