I want to know if it's possible having something like this:
- basic class A
- derived class B1 from one instance a of class A (i.e.
a = new A()) - derived class B2 from same instance a of A
I give an example:
var a = new A();
function A() {
this.var_test = 0;
this.test = function () {
alert(this.var_test++);
}
}
function B1() {
}
B1.prototype = a;
function B2() {
}
B2.prototype = a;
var b1 = new B1();
var b2 = new B2();
b1.test(); // i want alert(0)
b2.test(); // i want alert(1)
How to do it?