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();
原文地址:https://www.cnblogs.com/web-fusheng/p/6764187.html