factit = function factorial(n) { console.log(n) if (n < 2) { return 1; } return n * factorial(n - 1); } non_recursive = function(){} /* can't visit factorial here: as is indicated in `Runtime Semantics: Evaluation` of NAMED function expression, we will NewDeclarativeEnvironment(scope) as a middle env to recv factorial from ecma: The BindingIdentifier in a FunctionExpression can be referenced from inside the FunctionExpression's FunctionBody to allow the function to call itself recursively. However, unlike in a FunctionDeclaration, the BindingIdentifier in a FunctionExpression cannot be referenced from and does not affect the scope enclosing the FunctionExpression. */
Friday, December 23, 2022
function expression
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment