// 简单工厂 function User (name, age, career, work) { this.name = name this.age = age this.career = career this.work = work } function Factory (name, age, career) { let work switch(career){ case 'coder': work= ['码代码','百度'] break case 'product manager': work= ['订会议室', '写prd', '催更'] break case 'boss': work= ['看报', '谈业务'] break } return new User(name, age, career, work) } let arr = ['张三', 18, 'coder'] console.log(Factory(...arr))