SOURCE

//实现new关键字的函数
function Person(name,age){
    this.name = name
    this.age = age
}
function _new(){
    let func1 = [].shift.call(arguments)
    let o = {}
    o._proto_ = func1.prototype
    let obj =  func1.apply(o,arguments)
    return (typeof obj == Object)?obj:o
}
let s = _new(Person,"zhao",20)
console.log(s._proto_ == Person.prototype)
console 命令行工具 X clear

                    
>
console