When a JS object is generated:
For example, function BB (){
This. A = "KKK"
}
VaR B = new BB ();
In this case, B is the prototype object pointed to by the prototype attribute of the object with BB;
The prototype object has the constructor attribute pointing to the BB function;
Therefore, alert (B. constructor = BB. Prototype. constructor) // true
Here, the "with" Execution Process is to first check whether B has this attribute, and then view the attribute values in prototype, rather than simply a = B:
Add B. constructor = "CCC ";
Execute: Alert (B. constructor = BB. Prototype. constructor) // false; Bb. Prototype. constructor is still a BB function;
Let's take a look at the inheritance of kissy in Taobao:
CopyCodeThe Code is as follows: O = function (o ){
Function f (){
}
F. Prototype = O;
Return new F ();
},
SP = S. prototype,
Rp = O (SP );
R. Prototype = RP;
// Alert (R. Prototype. constructor = sp. constructor)
RP. constructor = R;
// Alert (R. Prototype. constructor = sp. constructor)
R. superclass = sp;
At the beginning, I was wrong. I don't know how to use air conditioners.