@@ -122,3 +122,25 @@ Person.prototype = (function(){
122
122
1 . globals can be passed in parameters to the immediate function
123
123
* a module can create a constructor as well
124
124
* if you return the constructor function instead of an object
125
+
126
+ ## sandbox pattern
127
+
128
+ * addresses some namespace drawbacks: single global var, long dotted names
129
+
130
+ ``` js
131
+ new SandBox (' dependencies' , ' here' , function (box ){
132
+ // your code here
133
+ });
134
+ ```
135
+
136
+ * you have a single global constructor
137
+ * passed in callback function is you isolated environment
138
+ * you initiate multiple Sandbox object and even nest them
139
+ * you can name the constructor appropriately (instead of Sandbox)
140
+
141
+ ## implementing the sandbox pattern
142
+
143
+ * as the Sandbox function is an object we can add a modules (object) property to it
144
+ * add required modules to ``` this ```
145
+ * then call callback with ``` this ```
146
+ * the callback is the users sandbox and get populated with the requested functionality
0 commit comments