ES6派生类构造函数初始化

时间:2019-01-16 07:57:47

标签: es6-class

为什么未打印console.log的输出。

Vehical类{

    constructor( wheel, type, model, make ) {
        this.wheel = wheel;
        this.type = type;
        this.model = model;
        this.make = make;
        console.log('call vehical');
    }

    getVehicalBasicDetails() {
        return `It's ${this.make} company's ${this.type} vehical having ${this.wheel} wheels and made in year ${this.model} `;
    }

}


class Car extends Vehical{

    constructor(wheel, type, model, make, make2 ) {
        console.log( 'call car');
        // super(wheel, type, model, make);

        this.wheel = wheel;
        console.log( this.wheel );
        console.log('call car1');
    }
}

var jazz = new Car( 4, 'Hatch back', 2015, 'Honda', 1);
console.dir( jazz );
console.log( jazz.getVehicalBasicDetails() );

在es6上运行

为什么派生类构造函数中没有super()方法调用时,console.log不打印?

0 个答案:

没有答案