Skip to content

Instantly share code, notes, and snippets.

@zhannes
Created November 30, 2012 16:56
Show Gist options
  • Save zhannes/4176977 to your computer and use it in GitHub Desktop.
Save zhannes/4176977 to your computer and use it in GitHub Desktop.
javascript scoping - 3
/* #########################
3 - SCOPE - Define a function in a closure, return an object that has access to that function.
*/
(function(){
// accessible via the object we return
var o = (function(){
// local
function _f(){ _log( 'danneh' ); }
// public exports
return {
foo: _f
};
})();
o.foo(); // works, and no-one can modify _foo
_log( this._f ); // undefined
})();
_log( window._f ); // undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment