1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| class People { constructor(height, money) { this.height = height; this.money = money; } work() { console.log('I am working'); } play() { console.log('I am playing'); } info() { console.log('我身高',this.height, '我有',this.money); } }
let cMan =new People ('0cm','0元');
class aMan extends People { swim() { console.log('aMan','I am swimming'); } };
let poolMan = new aMan('165cm', '5億');
class bMan extends People { constructor(height, money, face) { super(height, money); this.face = face; } swim() { console.log('bMan','I am swimming'); } talk() { console.log('bMan','I am talking'); } info() { console.log('我身高有',this.height, '我錢有',this.money,'我臉很',this.face); } };
let richMan = new bMan('195cm','500億','帥');
|