【发布时间】:2015-05-24 20:58:53
【问题描述】:
function A() {}
A.prototype.x = 10;
var a = new A();
alert(a.x); // 10
A.prototype = {
x: 20,
y: 30
};
alert(a.y) // undefined
- 为什么它委托给
old prototype of a.x而不是新的 一个? - 为什么
a.y会通过undefined投掷prototype?
【问题讨论】:
标签: javascript inheritance prototype