You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionfoo(){varobj=newObject();varconstructor=Array.prototype.shift.call(arguments)//构造函数obj.__proto__=constructor.prototype;varresult=constructor.apply(result,arguments);returnresultinstanceofObject ? result : obj;}
The text was updated successfully, but these errors were encountered:
new原理
初步实现
思考
当构造函数有返回值时呢?
如果返回值是一个对象,我们就返回这个对象,如果没有,我们返回生成的对象。
最终版
The text was updated successfully, but these errors were encountered: