function new(){
const obj = {};
const fn = [].shift.call(arguments);
obj.__proto__ = fn.prototype;
const result = fn.apply(obj,arguments);
return typeof result === 'object' ? result : obj;
}
new的原理
最新推荐文章于 2023-11-06 23:17:56 发布