I am reading ECMAScript Language Specification Function Calls section
Can someone rephrase or detailed explains the following sentense for me?
The production CallExpression :
MemberExpression Arguments is
evaluated as follows:
- Evaluate MemberExpression.
let’s take this code as an example.
var john = {
name: 'John',
greet: function(person) {
alert("Hi " + person + ", my name is " + this.name);
}
};
john.greet("Mark");
Take above code as an example, what does production CallExpression mean? what is MemberExpression in this case, john.greet?
Thanks!
The MemberExpression is
john.greet. Basically what it’s saying is: Step 1: Figure out what function to call. 🙂 Thejohnpart is important, because it comes into it later.Here’s the complete quote from the most recent specification (your link is to the 3rd edition, which has been superceded by the 5th edition; this didn’t change much though):
As you can see,
johncomes into it again at 6(a) because the expression is a property reference, so thethisvalue isjohn(rather than the global object, as it would be if you called this not through a property reference).If you’re reading the spec, I do recommend reading the newest one instead of the older one (no HTML version yet). I’m afraid the prose is no less turgid, though. 🙂