Skip to content

Instantly share code, notes, and snippets.

@andybeeching
Forked from padolsey/gist:303362
Created February 13, 2010 19:48
Show Gist options
  • Save andybeeching/303647 to your computer and use it in GitHub Desktop.
Save andybeeching/303647 to your computer and use it in GitHub Desktop.
var foo = 'bar';
(function(){
var window,top,self,parent,global;
// How do you get the global object here?
// http://www.quirksmode.org/dom/w3c_html.html
console.log( (document.defaultView || document.parentWindow).foo ); //==> bar
}).call({});
// This works also (though less intuitive)
var baz= 'far';
(function(){
var window,top,self,parent,global;
// How do you get the global object here? Trick from Andrea Giammarchi
// http://webreflection.blogspot.com/2010/02/jslint-bad-part.html
console.log( [].sort.call(null).baz); //==> far
}).call({});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment