企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
[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(); ~~~