💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] ## 1.创建一个对象 ~~~ class Person{ constructor(name,age){ this.name = name; this.age = age; } sayName(){ console.log(this.name) } } let cheng = new Person("cheng",18); cheng.sayName(); ~~~ ## 2.extends继承 ~~~ class Person{ constructor(name,age){ this.name = name; this.age = age; } sayName(){ console.log(this.name) } } class Teacher extends Person{ constructor(name,age,skill){ super(name,age); this.skill = skill; } saySkill(){ console.log(this.skill); } } let cheng = new Teacher("cheng",18,"HTML5"); cheng.saySkill(); ~~~