手写bind 和

 let arr = {
            name:"liu"
        }
        let res = {
            res1:"hao",
            test(a,b,c){
                console.log(this,a,b,c)
            }
        }
        Function.prototype.mybind = function(arr,res){
            let Fs = this
            return ()=>{
                let ssr = Symbol.for('func')
                arr.__proto__[ssr] = Fs
                arr[ssr](...res)
            }
        }
        res.test.mybind(arr,[1,2,3])()

 

posted @ 2020-12-13 20:51  刘葵  阅读(57)  评论(0编辑  收藏  举报