【发布时间】:2015-09-22 07:52:59
【问题描述】:
我有:
// prototype object
var x = {
name: "I am x"
};
// object that will get properties of prototype object
var y = {};
// assign the prototype of y from x
y.prototype = Object.create( x );
// check
console.log( y.__proto__ );
结果:
为什么?我做错了什么?
【问题讨论】:
-
prototype属性仅适用于函数对象。否则它只是另一个属性。
标签: javascript inheritance prototype prototypal-inheritance