构造函数的__proto__
function Animal(){
}
var anim = new Animal();
Object.__proto__===Function.prototype //true
Array.__proto__===Function.prototype //true
Animal.__proto__===Function.prototype //true
Function.prototype===Function //false
Function.prototype.constructor===Function //true
Object Array Animal都是由Function new出来的,所以他们的__proto__都指向Function.prototype
Function.prototype上面挂载的有bind call apply toString等方法。
普通对象
anim.__proto__===Animal.prototype //true
Animal.prototype.proto===Object.prototype //true
Object.prototype.proto===null; //true
--> anim.proto.proto.proto===null
var dog={};
dog.proto===Object.prototype //true
Object.prototype.proto===null //true
-->dog.proto.proto===null //true
每个普通对象的__proto__都指向其构造函数的prototype
每个对象的__proto__都指向其构造函数的prototype(除了Object.prototype.__proto__===null //true)
dog与anim相比,少了一层__proto__
Js中Prototype、__proto__、Constructor、Object、Function关系介绍 (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|