bind

Function.prototype.myBind = function(obj,...rest){
    let that = this
    let bound = function(...args){
        let params = [...rest,...args]
        that.apply(this.constructor === that ? this : obj,params)
    }
    bound.prototype = that.prototype
    return bound
}

https://www.cnblogs.com/echolun/p/12178655.html

原文地址:https://www.cnblogs.com/zhenjianyu/p/13207315.html