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的原理
最新推荐文章于 2022-10-15 11:55:47 发布