js类 的小例子

 

 

class Flyer {
    constructor(fname, speed) {
      this.fname = fname;
      this.speed = speed;
    }
    fly(){
      console.log(this.fname,this.speed)
    };
  }
  class Plane extends Flyer{
    constructor(fname,speed,score) {
      super(fname,speed);
      this.score=score;
    }
    getScore(){
      console.log(this.fname,this.speed,this.score);
    };
  }
  var F16=new Plane('f16','100','50');
  F16.fly();
  F16.getScore();

 

posted @ 2017-04-25 20:31  快乐的咸鱼  阅读(223)  评论(0编辑  收藏  举报