function animal() {
this.type = '动物';
}
function cat(name,color) {
this.name = name;
this.color = color;
}
function cat(name,color) {
animal.apply(this,arguments);
this.name = name;
this.color = color;
}
var cat1 = new cat("haha", 'red');
console.log(cat1.type); //动物
function extend(Child, Parent) {
var p = Parent.prototype;
var c = Child.prototype;
for (var i in p) {
c[i] = p[i];
}
c.uber = p; //桥梁作用
}
extend(cat, animal);
var cat1 = new cat("haha","red");
alert(cat1.type); // 动物
cat.prototype = new animal();
cat.prototype.constructor = cat;
var cat1 = new cat("haha","red");
console.log(cat1.constructor == cat); //true
console.log(cat1.type); // 动物
cat.prototype = new animal();
var cat1 = new cat("haha", 'red');
console.log(cat1.constructor == animal); //true
function animal() {
}
animal.prototype.type = '动物';
cat.prototype = animal.prototype;
cat.prototype.constructor = cat;
var cat1 = new cat("haha","red");
console.log(cat1.type); // 动物
var F = function(){};
F.prototype = animal.prototype;
cat.prototype = new F();
cat.prototype.constructor = cat;
function extend(Child, Parent) {
var F = function(){};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.prototype.constructor = Child;
Child.uber = Parent.prototype;
}
extend(cat,animal);
var cat1 = new cat("haha","red");
console.log(cat1.type); // 动物
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有