function Car(carbrand,model){
this.carbrand=carbrand;
this.model=model;
}
Car.prototype.Acce=function(){
console.log('this is '+this.carbrand+'---'+this.model)
}
Car.prototype.hoot=function(){
console.log('嘟嘟嘟。。')
}
Car.prototype.lun=4;
var car =new Car('aa','bb');
car.hoot();
car.Acce();
function Tesla(carbrand,model,power){
Car.call(this,carbrand,model);
this.power=power;
}
Tesla.prototype=Object.create(Car.prototype);
console.log(Tesla.prototype.constructor)
Tesla.prototype.constructor=Tesla;
console.log(Tesla.prototype.constructor)
Tesla.prototype.Power=function(){
console.log(this.power);
}
var tes=new Tesla('tes','car','dian');
tes.hoot();
tes.Acce();
Tesla.prototype.Acce=function(){
console.log('this is testla');
}
tes.Acce();
tes.Power();
console.log(car.lun);
console.log(tes.lun)
console.log(typeof Tesla)
结果
