javascript 面向?qū)ο笫菍崿F(xiàn)類的多重繼承。具體代碼如下:
function multipleinheritPrototype() {
if (arguments.length == 0) {
return;
}
var args = arguments;
var sub = args[0];
var constructor = sub.prototype.constructor;
if (!Object.create) {
Object.prototype.create = function (obj) {
function f() {
}
f.prototype = obj;
return new f();
};
}
var base;
for (var i = 1; i < args.length; i++) {
base = Object.create(args[i].prototype);
for (var attr in base) {
sub.prototype[attr] = base[attr];
}
}
sub.prototype.constructor = constructor;
}
更多信息請查看IT技術(shù)專欄