foo1
并foo2
从人那里继承。为什么是foo1.a
一样的foo2.a
?
var foo1, foo2;
var person = function(a) {
this.a = []
this.b = 1;
console.log('construct 1');
}
var kevin = function(a, b) {
console.log('construct 2');
}
kevin.prototype = new person();
foo1 = new kevin();
foo2 = new kevin();
foo1.a[3] = true;
foo1.a[1] = true;
foo2.a[1] = false;
foo1.b = 2;
foo2.b = 3;
console.log(foo1.a);
console.log(foo1.b);
console.log(foo2.a);
console.log(foo2.b);
为什么是foo*.a
共享的?为什么不foo*.b
共享?