ES6 Class
class human {
constructor(height, weight){
this.height = height;
this.weight = weight;
}
get getHeight() {
return this.height;
}
}
const alice = new human(178, 67);
console.log(alice);
// 178Static
class human {
constructor(height, weight){
this.height = height;
this.weight = weight;
}
static fly() {
console.log(this)
console.log(new this(12,12));
}
}
human.fly();class 均為嚴格模式執行 (no autoboxing)
繼承父 class
class 換成 function
不同class 傳遞參數
呼叫父類別方法
Last updated