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

posted @ 2020-06-29 12:02  671_MrSix  阅读(128)  评论(0编辑  收藏  举报