1.创建一个空对象,这个变量引用该对象,//lattarget={};2.继承函数的原型。//target.proto=func.prototype;3.给this引用的对象添加属性和方法。并执行函数func//func.call(target);4、新创建的对象被this引用,最后隐式返回this。//如果func.call(target)返回的res是对象或函数,则返回它functionnew(func){lattarget={};target.__proto__=func.prototype;letres=func.call(target);if(typeof(res)=="object"||typeof(res)=="function"){returnres;}returntarget;}
