function myNew(func,...args){ const obj = Object.create(func.prototype) const result = func.apply(obj,args) return typeof result === 'object'?result:obj } function Person(name, age) { this.name = name; this.age = age; } // 使用 myNew 模拟 new 操作符 const person1 = myNew(Person, 'Alice', 30); const person2 = myNew(Person, 'Bob', 25); console.log(person1); // 输出: Person { name: 'Alice', age: 30 } console.log(person2); // 输出: Person { name: 'Bob', age: 25 }