new | function extend() {
var len = arguments.length;
var body = arguments[len - 1];
var parent = (len > 1) ? arguments[0] : Function.constructor;
body.prototype = new parent;
var constructor = new body;
constructor._super = parent.prototype;
if (!constructor.hasOwnProperty("init")) return body;
constructor.init.prototype = constructor;
return constructor.init;
}
function A1() {this.a1=12324233243;}
A1.prototype.a2=222222;
var A = extend(A1, function () {
console.log(1)
this.pro1 = 'pro1 ';
this.method1 = function() {
return this.pro1;
}
this.init = function(a) {
}
});
var B = extend(A, function() {
console.log(2)
this.pro2 = 'pro2 ';
this.init = function(a) {
};
this.method2 = function() {
return this.pro1 + this.pro2;
};
});
ins=new B("parameter")
console.log(ins instanceof B, ins)
| ready |
copying prototype | function extend() {
var len = arguments.length;
var body = arguments[len - 1];
var parent = (len > 1) ? arguments[0] : Function.constructor;
body.prototype = parent.prototype;
var constructor = new body;
constructor._super = parent.prototype;
if (!constructor.hasOwnProperty("init")) return body;
constructor.init.prototype = constructor;
return constructor.init;
}
function A1() {this.a1=12324233243;}
A1.prototype.a2=222222;
var A = extend(A1, function () {
console.log(1)
this.pro1 = 'pro1 ';
this.method1 = function() {
return this.pro1;
}
this.init = function(a) {
}
});
var B = extend(A, function() {
console.log(2)
this.pro2 = 'pro2 ';
this.init = function(a) {
};
this.method2 = function() {
return this.pro1 + this.pro2;
};
});
ins=new B("parameter")
console.log(ins instanceof B, ins)
| ready |
othr | function extend() {
var len = arguments.length;
var body = arguments[len - 1];
var parent = (len > 1) ? arguments[0] : Function.constructor;
body.prototype = parent.prototype;
var constructor = new body;
if (!constructor.hasOwnProperty("init")) return body;
constructor._super = parent.prototype;
constructor.init.prototype = constructor;
return constructor.init;
}
function A1() {this.a1=12324233243;}
A1.prototype.a2=222222;
var A = extend(A1, function () {
console.log(1)
this.pro1 = 'pro1 ';
this.method1 = function() {
return this.pro1;
}
this.init = function(a) {
}
});
var B = extend(A, function() {
console.log(2)
this.pro2 = 'pro2 ';
this.init = function(a) {
};
this.method2 = function() {
return this.pro1 + this.pro2;
};
});
ins=new B("parameter")
console.log(ins instanceof B, ins)
| ready |
asa | function extend() {
var len = arguments.length;
var body = arguments[len - 1];
var parent = (len > 1) ? arguments[0] : Function.constructor;
body.prototype = parent.prototype;
var constructor = new body;
if (!constructor.hasOwnProperty("init")) return body;
constructor._super = parent.prototype.init;
constructor.init.prototype = constructor;
return constructor.init;
}
function A1() {this.a1=12324233243;}
A1.prototype.a2=222222;
var A = extend(A1, function () {
console.log(1)
this.pro1 = 'pro1 ';
this.method1 = function() {
return this.pro1;
}
this.init = function(a) {
}
});
var B = extend(A, function() {
console.log(2)
this.pro2 = 'pro2 ';
this.init = function(a) {
};
this.method2 = function() {
return this.pro1 + this.pro2;
};
});
ins=new B("parameter")
console.log(ins instanceof B, ins)
| ready |