functionobjectFactory(){let newObject =null;let constructor =Array.prototype.shift.call(arguments);let result =null;//判断参数是否是一个函数if(typeof constructor !=='function'){
console.error('type error')return}//新建一个空对象,对象的原型为构造函数的prototype对象
newObject = Object.create(constructor.prototype)//将this指向新建对象,并执行函数
result =constructor.apply(newObject, arguments)//判断返回对象let flag = result &&(typeof result ==='object'||typeof result ==='function')return flag ? result : newObject
}functionPerson(name, age, score){this.name = name
this.age = age
this.score = score
return{name:this.name }}let rest =objectFactory(Person,'dmc',21,100)
console.log(rest)