哪种情况下__proto__和prototype的指向是同一个?

新手上路,请多包涵

哪种情况下__proto__和prototype的指向是同一个?

阅读 2.6k
2 个回答

举一个例子Function

Function.__proto__ === Function.prototype; //true

其他的,比如手动修改__proto__也可以做到,这种就没办法判断。

var A = function(){}
A.__proto__ = A.prototype

A.__proto__ === A.prototype; //true

一个实例对象的__proto__属性指向自身构造函数的原型链,即:

var arr = new Array();
console.log(arr.__proto__ === Array.prototype) // => true;
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题