SOURCE

function test(bs) {
    this.b = bs;
    return {
        a : 3
    }
}
function _new(fn,...arg) {
    const obj = Object.create(fn.prototype);
    const res = fn.apply(obj,arg);
    return res instanceof Object ? res : obj;
    // return obj;
}
console.log(_new(test, 5));
console.log(new test());
console 命令行工具 X clear

                    
>
console