In this proposed alternative to sloppy-mode function hoisting semantics, sloppy-mode FunctionDeclaration are always single var
-style bindings. The var
is set to the value of the function at the top of the block where the FunctionDeclaration occurs. I believe these semantics roughly match IE10 and earlier sloppy mode function hoisting semantics.
- Maintain compatibility at the intersection of what browsers have supported for a long time
- Support is self-defining functions defined in blocks (tc39/ecma262#162)
- If possible, be intelligible for users and implementors (simple semantics win out when they make sense)
- Preserve strict-mode lexical scoping of FunctionDeclarations (this proposal only affects sloppy mode)
- Make a lexical binding in sloppy mode, and generally try to make sloppy mode block-scoped FunctionDeclarations act like lexical bindings, including suppressing errors, when possible