javascript中__proto__和prototype的区别

__proto__是真正的原型链,对象特性在__proto__上查找。

prototype是构造__proto__的对象。

两者存在联系,用代码表示

function Robot(name) {
    this.name = name;
}
var robot = new Robot();

// the following are true   
robot.__proto__ == Robot.prototype
robot.__proto__.__proto__ == Object.prototype

  

 

posted @ 2018-03-12 18:02  xuyv  阅读(92)  评论(0编辑  收藏  举报