📜  如何在 javascript 代码示例中创建类的实例

📅  最后修改于: 2022-03-11 15:04:11.288000             🧑  作者: Mango

代码示例1
class Hello {
    person(name){
        this.name = name;
    }
      // Constructor - Important except for JSX
    constructor(name){
        this.person(name);
        console.log(`Hello ${this.name}`);
    }
}

const helloInstance = new Hello('john doe');