Created
November 29, 2011 15:54
-
-
Save joshnesbitt/1405289 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(window) { | |
| // stuff that uses window a lot here... | |
| })(window); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In this instance, assume you are operating inside a closure, and that there is a lot of code in the anonymous function that accesses the
windowproperty.If the
windowproperty was not passed into the local scope, every timewindowwas accessed it would have to traverse up to the top level scope to find the actualwindowobject. By passing it into the local scope we save any further lookups other than the current scope, reducing more intensive lookups to the top level scope.