function Person(name,age){
this.age=age
this.name=name
return {gree:'gg'}
// return name
}
function newFun(fun, ...args) {
// 1.先创建一个空对象
let newObj = {}
// 2.把空对象和构造函数通过原型链进行链接
newObj.__proto__ = fun.prototype
// 3.把构造函数中得this绑定到新的空对象身上
const result = fun.apply(newObj, args)
// console.log(newObj,'111');
// 4.根据我们构建的函数返回的数据类型判断 如果是值类型则返回对象 如果是引用类型就要返回这个引用类型
return result instanceof Object ? result : newObj
}
const newObj=newFun(Person,'alice',25)
console.log(newObj);//