🈯function declaration
🚧 施工中
JS ⟩ declaration ⟩ function declaration
function declaration vs. variable declaration
function declaration is instantly fully initialized.
variable declaration is assigned undefined initially. (👉 hoisting)
📗 JS.info ⟩ Function Declarations
in sloppy mode:hoisted and visible outside the block❗
in strict mode:local to the block❗
function declaration in the global scope
also expose themselves as global object property. 👉 global var / function is global object property❗️❗
⭐ 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 parameter(s) and function(s) are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during evaluation of the function body.
Last updated