Skip to content

Instantly share code, notes, and snippets.

@kangax
Created November 11, 2008 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kangax/23934 to your computer and use it in GitHub Desktop.
Save kangax/23934 to your computer and use it in GitHub Desktop.
// Only one closure is created here - i.e. when one of these functions is returned from within anonymous-outer one.
// That returned function will be part of the closure and have access to [[Scope]] of anonymous-outer one.
// The returned function is the only Function object that's being created.
// Function expressions from other blocks are never reached and so are never created
var globalEval = (function(){
if (window.eval) {
return function(s){ window.eval(s) }
}
else if (window.execScript) {
return function(s){ window.execScript(s) }
}
return function(s){
// use script insertion
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment