派生对象可以从其原型对象中获取属性值; 但是当设置该属性时,它将在派生对象中添加新属性。 更多内容见下面的代码。
function Base(name) {this.name = name };
function Deriver(name) {this.dname = name };
var base = new Base('base');
Deriver.prototype = base ;
d1 = new Deriver('d1');
console.log(d1.name); // it will show "base". That'ok.
d1.name = "new name"; // !!! it does not update the property from its protoype object
// it add new property "name" in the object d1.
console.log(d1.name); // it will show "new name"
console.log(base.name); // it still show "base"