SOURCE

function myNew(fn, ...args) {
    let obj = {}
    obj.__proto__ = fn.prototype
    const result = fn.apply(obj, args)
    return result instanceof Object ? result : obj
}
console 命令行工具 X clear

                    
>
console