Function scoping in strict mode
suggest changeIn Strict Mode, functions declared in a local block are inaccessible outside the block.
"use strict";
{
f(); // 'hi'
function f() {console.log('hi');}
}
f(); // ReferenceError: f is not defined
In strict mode the declaration is scoped to the block, but it is hoisted inside that block, so the call above the declaration runs. A let or const binding would still be in the temporal dead zone there. Sloppy-mode block functions follow older, less predictable rules.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents