🈯function declaration
🚧 施工中
Last updated
Was this helpful?
🚧 施工中
Last updated
Was this helpful?
Was this helpful?
JS ⟩ declaration ⟩ function declaration
creates a function object and assigns it to the specified name (an identifier).
// function declarations
function f(params) { ... } // normal function
function* f(params) { ... } // generator function
async function f(params) { ... } // async function
async function* f(params) { ... } // async generator function
function declaration vs. variable declaration
function declaration is instantly fully initialized.
is assigned initially. (👉 )
📗 JS.info ⟩
in : and visible outside the
function declaration in the
also expose themselves as . 👉 ❗
⭐ instantiation
When an is established for evaluating an ECMAScript :
in strict mode:local to the block❗
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.