>(function(){ if(false) var window; return window }()) === window
>JavaScript interpreter checks all variable declarations in scope before execution.
This is another way of saying that all variable declarations are scoped at the function level, not the individual block level. This is why generating closures in a loop is broken in javascript (Although in just about every other language as well, closures in a loop give surprising results at first - including, I think, arc?)
To get a new scope, you have to use the anonymous function trick:
>JavaScript interpreter checks all variable declarations in scope before execution.
This is another way of saying that all variable declarations are scoped at the function level, not the individual block level. This is why generating closures in a loop is broken in javascript (Although in just about every other language as well, closures in a loop give surprising results at first - including, I think, arc?)
To get a new scope, you have to use the anonymous function trick: