JavaScript Advanced programming (3rd Edition) P144
the meaning expressed in (2). It"s not what I understand.
-reference elevation content start-
English explanation
To create a new instance of Person, use the new operator. Calling a constructor in this manner
essentially causes the following four steps to be taken:
- Create a new object.
-
Assign the this value of the constructor to the new object (so this points to the new object).
PS: (assign the value of the constructor"s this to the new object) - Execute the code inside the constructor (adds properties to the new object).
- Return the new object.
-reference elevation content end-
here is my understanding of the steps to call the constructor using the new keyword.
(1). Var newobj = {}; / / first create a new temporary object
(2) .newobj.call (newobj); / / execute the constructor in the scope of the new object.
that is, assign newobj to this. The book says the opposite. Assign the value of the constructor"s this to the new object. How to understand this sentence?