const Dog = function(name) {
this.name = name
}
Dog.prototype.say = function() {
console.log(this.name)
}
function myNew(fn, ...args) {
// 创建空对象 obj
const obj = Object.create(fn.prototype)
// 通过apply this指向object
const ret = fn.apply(obj, args)
return ret instanceof Object ? ret : obj
}
const test1 = myNew(Dog, 345)
test1.say()