1.ES6 中有 class 语法。值得注意是,这里的 class 不是新的对象继承模型,它只是原型链的语法糖表现形式。
函数中使用 static 关键词定义构造函数的的方法和属性:
class声明的本质是function
<script type="text/javascript">
// 创建一个类
class Animal{
constructor(name) {
this.name = name;
}
say(){
console.log("我开始怒吼!");
}
}
class Cat extends Animal{
constructor(name,color){
super(name);
this.color=color;
}
skill(){
console.log(`我的名字是${this.name}我是高贵的${this.color}`);
console.log("我的任务是要到小鱼干");
}
}
// 实例化类=类(实例化对象)
var c1 = new Cat("小花","花白色");
var c2 = new Cat("小白",