We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 30c72b1 commit f20cce9Copy full SHA for f20cce9
05-object-creation.md
@@ -50,3 +50,31 @@ function myFunction(){
50
* shorter to type module names afterwards
51
* deps in one place
52
* some minifiers won't shorten global var names
53
+
54
+## private members with closures
55
56
+* constructor function create a closure
57
+* any variables part of constructor closure are not visible outside of it
58
59
+```js
60
+function Person(){
61
+ var secret = 'hey';
62
+ return {
63
+ doIt: function (){
64
+ // can see secret
65
+ }
66
67
+}
68
69
+var me = new Person();
70
+me.secrect === undefined;
71
+secret === undefined;
72
+me.doIt(); //does it
73
+```
74
75
+* privileged methods are the ones declared within the constructor
76
+* privileged methods have access to private members
77
+* old versions of Firefox allowed access to private scope
78
+* internal arrays/objects are still modifiable via reference
79
+* make sure you return a new object with only the properties needed by caller
80
+* or copy your objects/arrays (with utility methods)
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments