Created
February 6, 2012 16:57
-
-
Save laustdeleuran/1753301 to your computer and use it in GitHub Desktop.
Referencing scoped functions in the global namespace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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