In this blog post, it says that the argument object is created and assigned its value during creation of execution context, before any code is executed. However, in the book, YDKJS by Kyle Simpson, there is an example that looks like this,
function foo(a) {
console.log( a ); // 2
}
foo( 2 );
and he says that the assignment of value '2' to the argument 'a' happens after the creation of execution context and during the code execution.
I've been trying to find a scenario where both would make sense but they seem like total opposite claims. When is the argument object created exactly? Thank you in advance!
First the arguments list object is created on the caller side.
Then it's passed into the EvaluateDirectCall
(or any other internal method that ends up calling a function) and then the execution context is created.
And after that when code evaluates - the references to the variables are obtained from the execution context.
All from above in details: FunctionDeclarationInstantiation