instanceof
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
class People {
constructor(name, age, sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
sayHello() {
console.log("大家好,我是" + this.name + ",我今年" + this.age + "岁, 我是" + this.sex + "的")
}
}
class Child extends People {
constructor(name, age, sex, height, weight) {
super(name, age, sex);
this.height = height;
this.weight = weight;
}
jump() {
console.log("u jump i jump")
}
}
var c1 = new Child("小明", 13, "男", 160, 200);
var p = new People("小红", 13, '女');
console.log(c1 instanceof Child);
console.log(c1 instanceof People);
</script>
</body>
</html>