SOURCE

class Staff {
    constructor(name, age, career, work) {
        this.name = name
        this.age = age
        this.career = career
        this.work = work
    }
}

const works = {
    'coder': ['写代码','写系分', '修Bug'],
    'product manager': ['订会议室', '写PRD', '催更'],
    'boss': ['喝茶', '看报', '见客户']
}

function staffFactory(name, age, career) {
    return new Staff(name, age, career, works[career])
}

const xiaoming = staffFactory('小明', 18, 'boss')
console.log(xiaoming.work)
console 命令行工具 X clear

                    
>
console