Javascript 为什么调用实例uuu proto_uuuu会返回对象{},而不是它设置为的实例?

Javascript 为什么调用实例uuu proto_uuuu会返回对象{},而不是它设置为的实例?,javascript,Javascript,为什么调用b.uu proto_u返回Object{}而不是a var a = { x: 10, calculate: function (z) { return this.x + this.y + z; } }; var b = { y: 20, __proto__: a }; var c = { y: 30, __proto__: a }; 为什么调用b.proto返回对象{},而不是a 因为名称a只是一个名称,指示如何使用x=10和计算方法引用该

为什么调用
b.uu proto_u
返回
Object{}
而不是
a

var a = {
  x: 10,
  calculate: function (z) {
    return this.x + this.y + z;
  }
};

var b = {
  y: 20,
  __proto__: a
};

var c = {
  y: 30,
  __proto__: a
};

为什么调用b.proto返回对象{},而不是a

因为名称
a
只是一个名称,指示如何使用x=10和计算方法引用该对象

例如,如果您
从该代码(作为函数)返回
c
,则名称
a
将完全没有意义

function foo(){
    var y = {x: 5};
    var z = { __proto__ : y }; // better to use Object.create
    return `;
}

// in someone else's code
var a = foo();
a.__proto__; // y wouldn't mean anything to me here, I'm not even aware of that it
a.x; // 5

你是什么意思,我测试了
b.uu-proto\uuu===a
@要查看附带的快照,你是否希望在控制台中键入
a
时它返回
a
Object{x:10}
a