10 biggest JS pitfalls
brendan at mozilla.com
Mon Dec 31 17:19:30 PST 2012
Yes, see the thread starting at
if you haven't.
The SpiderMonkey implementation was "first", for what it's worth -- from
1997. ES3 did not specify any function in block production, of course.
The intersection with IE semantics is such that it's safe to use the
function's name only later in the same block, but for some "then" blocks
where the condition happens to be always true, and a few others where
there's an outer definition of the same name -- the "if" condition is
object-detecting using typeof foo == "undefined", e.g., for wanted
function foo, then the function's name could be used after the "then"
block without error.
We may be able to evangelize, since as you discovered, people have
noticed the lack of interop already (that blog post is from 2011), so
there may not be too many sites depending on intersection semantics of
existing engines but not ES6 block-scoped (but not hoisted -- use after
Claude Pache wrote:
> I've just discovered that someone is fallen in the following pit:
> Change of the semantic of function declarations in Firefox when included in block (spoiler: hoisting issue).
> (Not standard ES for sure, but definitely JS.)
> Enjoy: http://statichtml.com/2011/spidermonkey-function-hoisting.html
More information about the es-discuss