class People{ constructor({name}){ this.name = name; } say(){ return "hello"; } } const people = new People({name:"tom"}); console.log(people); // People {name:"tom"} console.log(people.say()) //hello //继承 class Jack extends People{ //Jack 继承于 People constructor(options){ super(options) //调用super方法之前 要给类继承父级 this.age = options.age; } } const jack = new Jack({age:18,name:"jack"}) console.log(jack) //Jack {age:18,name:"jack"} console.log(jack.say()) //hello