这是访问父母财产的“好”方式吗?
function A(){
this.x = 5;
}
function B(parent){
this.parent = parent;
//this.x = parent.x; this does not work as a reference
}
B.prototype.x = function(){
return this.parent.x;
};
var a = new A();
var b = new B(a);
console.log(b.x());//5
a.x = 7;
console.log(b.x());//7