admin管理员组文章数量:1391995
I was trying to understand the prototype chain of the code below
const parentObject = {
name: "Parent",
nested: {
key: "value"
},
greet: function () {
return `Hello from ${this.name}`;
}
};
const childObject = Object.create(parentObject);
childObject.name = "Child";
console.log(childObject);
from which I get the following in the console:
Nonetheless, expanding constructor's prototype, then __proto__
I get
which points to a different __proto__
, null. Isn't the prototype of a constructor supposed to point to the original Object (in this case "parentObject")? If that is so, why they differ their proto?
If possible, is there a reliable diagram that well depicts what is going on?
版权声明:本文标题:javascript - why constructor's __proto__ is pointing to null while its original prototype doesn't? - Stack Overf 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744731819a2622091.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论