function A(){
// sort of like this
// this.arr = [];
}
function B(){
// not here though
// this.arr = [];
}
B.prototype = new A(); // all B instances would share this prototypes attributes
// I want all B instances to have an arr attributes (array)
// of their own but I want the parent class to define it
var b1 = new B();
var b2 = new B();
b1.arr.push(1);
b2.arr.push(2);
b1.arr.length === 1; // should be true
b2.arr.length === 1; // should be true
I want write code in A that would define a arr variable for each instance of a child class B such that arr is a new object for each B instance. I could make this happen by setting this.arr = [] in the B constructor, but is this possible to accomplish with code written onto A instead?