Сообщение от Diablo1909
Тогда вопрос... А почему просто не использовать так ? :
function P() { this.m = []; } function C() { P.call(this); } var a = new C(), b = new C(); alert(a.m==b.m); // false
|
Потому что так ты не наследуешь prototype методы:
function P() {
this.m = [ ];
}
P.prototype.method = function() {
this.m.push(Math.random());
}
function C() {
P.call(this);
}
C.method(); // Exception: 'method' is undefined