js 创建类

class Person{
        constructor(name, age){ // 构造器
            this.name = name;
            this.age = age;
        }
        
        // 一般方法
        speak(){
            console.log('我叫${this.name}, 年龄${this.age}')
        }
    }
class Student extends Person(){
    constructor(name, age, grade){
         super(name, age); 
         this.grade = grade;
    }
}

  

原文地址:https://www.cnblogs.com/ShanCe/p/14283325.html