Home >Web Front-end >JS Tutorial >The execution process of javascript new fun_js object-oriented

The execution process of javascript new fun_js object-oriented

WBOY
WBOYOriginal
2016-05-16 18:21:351291browse

(1) Create a new object and let this pointer point to it;
(2) Assign all members of the function’s prototype object to this new object;
(3) Execute the function body and modify this object Perform initialization operations;
(4) returns the object created in (1).
The execution process of javascript new fun_js object-oriented

Copy code The code is as follows:

function BB(a){
this.aa();
alert("s");

}
//alert(typeof BB.prototype.constructor);
BB.prototype.aa= function(){alert("sss");}
var nn=new BB("cc");
//var nn={};BB.apply(nn)
//nn= BB.prototype;

alert(nn.constructor);
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