Home  >  Article  >  Web Front-end  >  What is the running process of new operator in js

What is the running process of new operator in js

一个新手
一个新手Original
2017-09-08 13:31:592150browse


例:var obj = new Base(); 
该步一共做了三件事:即 
   var obj  = {}; obj.__proto__ = Base.prototype; Base.call(obj);  

第一行,我们创建了一个空对象obj
第二行,我们将这个空对象的__proto__成员指向了Base函数对象prototype成员对象
第三行,我们将Base函数对象的this指针替换成obj。

The above is the detailed content of What is the running process of new operator in js. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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