ES6继承关键字
/*
ES6的继承的关键字 => 儿子 extends 爹
继承: 儿子将父亲里面的内容给继承一份过来
狗:
属性
name
age
方法
eat
鸡:
属性
name
age
方法
eat
可以将相同的属性与方法给抽取一根出来,鸡和狗可以继承这一份
*/
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Document</title>
</head>
<body>
<script>
class Animal{
constructor(name,age){
this.name = name;
this.age = age;
}
eat(){
console.log("吃");
}
}
class Ji extends Animal{
}
class Dog extends Animal{
}
const d = new Dog("李四",19)
console.log(d);
d.eat();
</script>
</body>
</html>