function New(){ let obj = {} let arr = Object.values(arguments) let constructor = arr.shift() let result = constructor.apply(obj,arr) return typeof result === "object"?result:obj; } function F(name,age) { this.name = name this.age = age this.getName = function() { console.log(name)//这里不对的 console.log(this.name)//这里对的 } } let obj = New(F,"xiaoming",18) console.log(obj) obj.name = "dawang" obj.getName()