ECMAScript6的原型

class Car {
  constructor(name){
    this.name = name;
  }
  getName(){
          
  }
}
class Ferrari extends Car{
  constructor(name){
    super(name);
  }
  getName(){
        
  }
}
let car = new Car();
let ferrari = new Ferrari();
console.log('Car.prototype',Car.prototype); // Object{}
console.log('Ferrari.prototype',Ferrari.prototype); // Car{}
console.log('car.constructor===Car',car.constructor===Car); // true
console.log('ferrari.constructor===Ferrari',ferrari.constructor===Ferrari); // true
console.log('car.__proto__===Car.prototype',car.__proto__===Car.prototype); //true
console.log('ferrari.__proto__===Ferrari.prototype',ferrari.__proto__===Ferrari.prototype); //true
console.log('Car.prototype',Car.prototype); // 对象
console.log('Car.prototype.getName',Car.prototype.getName);   // getName()函数

 

posted on 2017-06-08 18:03  沙滩海风  阅读(149)  评论(0编辑  收藏  举报

导航