-
-
Save andybeeching/303647 to your computer and use it in GitHub Desktop.
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
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