📜  工厂函数 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:11.561000             🧑  作者: Mango

代码示例1
function createPerson(firstName, lastName) {
    return {
        firstName: firstName,
        lastName: lastName,
        getFullName() {
            return firstName + ' ' + lastName;
        }
    }
}
Code language: JavaScript (javascript)