I'm currently working on some code based on John Resig -Simple JavaScript Inheritance.
And i'm having some trouble with the initialization of arrays. If i put an array as ...
I am trying to define a javascript class with an array property, and its subclass. The problem is that all instances of the subclass somehow "share" the array property:
function ClassA() { this.a=[]; this.aa=100; }
function ClassB() { }
ClassB.prototype = new ClassA;
ClassB.prototype.b=function(){return "classbb"};
for (var l in ClassB.prototype){
Array.prototype[l] = ClassB.prototype[l];
}
var array1 = [];
alert(array1.b());