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:

  1. 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):

  1. let ref result of evaluating memberexpression.
  2. let func getvalue(ref).
  3. let arglist result of evaluating arguments, producing internal list of argument values (see 11.2.4).
  4. if type(func) not object, throw typeerror exception.
  5. if iscallable(func) false, throw typeerror exception.
  6. 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).
  7. else, type(ref) not reference.
      a. let thisvalue undefined.
  8. 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

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -