Real World Func Decl in Block Scope Breakages
brendan at mozilla.com
Wed Dec 26 18:02:03 PST 2012
Brandon Benvie wrote:
> Unless I'm mistaken on how Spidermonkey handles function declarations
> in block scope, almost none of those examples will work correctly in
> Firefox. Most of them will work in every other major browser, but not
> in Firefox.
No, that's not so. The ancient (pre-ES3) SpiderMonkey function-in-block
semantics are like an assignment expression in effect, so if control
flow reaches the nested function declaration, the var-like binding will
be *created* and initialized. If control flow does not reach one of N
possible for a given name, then the var-like binding won't even exist.
Crazy but true.
The snippets Brian posted all look like they'll work in SpiderMonkey /
Firefox, at a glance from me. Let me know if I missed something.
More information about the es-discuss