โ—var can shadow parameter even in strict modeโ—๏ธ

๐Ÿšง under construction

JS โŸฉ variable โŸฉ shadowing โŸฉ var can shadow parameter even in strict mode.

parameter(s) can be shadowed by varโ—

โญ function declaration instantiation

When an execution context is established for evaluating an ECMAScript function๏ผš

  • a new Function Environment Record is created and bindings for each formal parameter are instantiated in that Environment Record.

  • Each declaration in the function body is also instantiated.

  • If the function's formal parameters do not include any default value initializers then the body declarations are instantiated in the same Environment Record as the parameters โ—

  • If default value initializers exist, a second Environment Record is created for the body declarations โ—

  • Formal parameters and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during evaluation of the function body.

๐Ÿ“˜ JS spec โŸฉ FunctionDeclarationInstantiation

Last updated