lhlGitHub / trisome

前端大厂进攻学习资料库
21 stars 1 forks source link

new #11

Closed 13168335674 closed 2 years ago

13168335674 commented 2 years ago
function _new(target, ...args) {
    const obj = Object.create(target.prototype);
    const ret = target.apply(obj, args);
    return typeof ret === 'object' ? ret : obj;
}