NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
[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(); ~~~