class Ml { constructor(opt) { this.name = opt.name || 'name'; this.key = opt.key || 'key'; } init = () => { this.name = 'init name'; this.age = 20; } } let ml = new Ml({ name: 'kklll' }); console.log(ml.name); ml.init(); console.log(ml.name,ml.age);