Home > Web Front-end > JS Tutorial > body text

What are the specific steps to instantiate an object using the new operator?

hzc
Release: 2020-06-28 13:38:21
Original
3709 people have browsed it

The specific steps to use the new operator to instantiate an object are: 1. Create an empty object obj; 2. Set up the prototype chain, that is, [obj. _proto _= constructor.prototype]; 3. Let the constructor This in points to obj; 4. Return the object obj.

What are the specific steps to instantiate an object using the new operator?

Generally when creating an instance, var obj = new constructor

new operator is here Mainly do four steps

  • Create an empty object obj

  • Set the prototype chain, that is, obj . _proto _ = construction Function.prototype ;

  • Let this in the constructor point to obj

  • Return the object obj

Recommended tutorial: "JS Tutorial"

The above is the detailed content of What are the specific steps to instantiate an object using the new operator?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template