/*
?*?Programming?Quiz:?Building?Classes?and?Subclasses?(2-3)
?*/
class?Vehicle?{
?constructor(color?=?'blue',?wheels?=?4,?horn?=?'beep?beep')?{
??this.color?=?color;
??this.wheels?=?wheels;
??this.horn?=?horn;
?}
?honkHorn()?{
??console.log(this.horn);
?}
}
//?your?code?goes?here
class?Bicycle?extends?Vehicle?{
????constructor(color,?wheels,?horn){
????????super(Vehicle);
????????this.wheels?=?2;
????????this.horn?=?'honk?honk';
????????this.color?=?'blue';
????}
}
const?myVehicle?=?new?Vehicle();
myVehicle.honkHorn();?//?beep?beep
const?myBike?=?new?Bicycle();
myBike.honkHorn();?//?honk?honk測試答案如下報錯如下為什么說Cannot read property 'name' of undefined?
ES6語法練習,繼承,Cannot read property 'name' of undefined
無無法師
2017-08-20 10:55:28