javascript - Confused with ECMAScript Language Specification Function Calls section -
i reading ecmascript language specification function calls section
can rephrase or detailed explains following sentense me?
the production callexpression : memberexpression arguments evaluated follows:
- evaluate memberexpression.
let's take code example.
var john = { name: 'john', greet: function(person) { alert("hi " + person + ", name " + this.name); } }; john.greet("mark");
take above code example, production callexpression mean? memberexpression in case, john.greet?
thanks!
the memberexpression john.greet
. it's saying is: step 1: figure out function call. :-) john
part important, because comes later.
here's complete quote recent specification (your link 3rd edition, has been superceded 5th edition; didn't change though):
- let ref result of evaluating memberexpression.
- let func getvalue(ref).
- let arglist result of evaluating arguments, producing internal list of argument values (see 11.2.4).
- if type(func) not object, throw typeerror exception.
- if iscallable(func) false, throw typeerror exception.
- if type(ref) reference,
a. if ispropertyreference(ref) true,
i. let thisvalue getbase(ref).
b. else, base of ref environment record
i. let thisvalue result of calling implicitthisvalue concrete method of getbase(ref).- else, type(ref) not reference.
a. let thisvalue undefined.- return result of calling [[call]] internal method on func, providing thisvalue value , providing list arglist argument values.
as can see, john
comes again @ 6(a) because expression property reference, this
value john
(rather global object, if called not through property reference).
if you're reading spec, recommend reading newest one instead of older 1 (no html version yet). i'm afraid prose no less turgid, though. :-)
Comments
Post a Comment