The behavior of new when creating an object with a constructor

Create an object with a constructor:
var obj=new typename(property value,...)
new: 4 things:
1. Create an empty object
2. Let the new child object inherit the constructor's prototype object settings (automatically set the new object's The __proto__ property points to the prototype object of the constructor)
3. Call the constructor:   1. this->new   2. this.property name=value: Add a new property to the object by force assignment, and save the property value 4. Returns the address of the new object, stored in a variable


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324941527&siteId=291194637