js继承实现

function Car(Name,Age){
  this.Name = Name;
  this.Age = Age;
}
Car.prototype.showAge = function(){
   alert(this.Age);
}

function MoCar(Name,Age){
   Car.call(this,Name,Age);
}
MoCar.prototype = new Car();
MoCar.prototype.showName = function(){
   alert(this.Name);
}

var obj = new MoCar("jianboqi",12);
obj.showName();
obj.showAge();

 

posted @ 2013-03-07 11:04  理想空间  阅读(185)  评论(0编辑  收藏  举报