Skip to content

Instantly share code, notes, and snippets.

@laustdeleuran
Created February 6, 2012 16:57
Show Gist options
  • Save laustdeleuran/1753301 to your computer and use it in GitHub Desktop.
Save laustdeleuran/1753301 to your computer and use it in GitHub Desktop.
Referencing scoped functions in the global namespace
(function(){
// Internal vars and functions
var s = 1,
t = 3,
internalFunction = function(){
return s+t;
},
externalFunction = function(){
return internalFunction();
};
// Reference the functions we want available in the global scope
window._v = new Object();
window._v.extFunc = externalFunction;
})();
console.log(window._v.extFunc());
// Outputs '4'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment