Difference between revisions of "Sandbox"

From Organic Design wiki
m
Line 4: Line 4:
  
 
var closure = ( function() {
 
var closure = ( function() {
    var foo = 1;
 
 
     return {
 
     return {
         bar: 100,
+
         foo: function() {
         baz: function() {
+
            private = 'secret message';
             this.foo2 = 'yo';
+
            public = 'not secret';
 +
        }
 +
         bar: function() {
 +
             alert( private );
 
         }
 
         }
 
     }
 
     }
 
} )();
 
} )();
closure.baz();
+
alert( closure.public );
alert( closure.foo2 );
+
alert( closure.private );
 
+
closure.bar();
 
});
 
});
  
 
</script></html>
 
</script></html>

Revision as of 15:27, 12 September 2012