美文网首页
自主实现bind函数

自主实现bind函数

作者: 阿凯_8b27 | 来源:发表于2019-11-25 09:18 被阅读0次

bind 函数特点,从第一个参数开始为函数参数,第二个为作用域,返回值是一个函数
function mgyBind(fn,context){

var out = Array.prototype.slice(arguments,2)

return function(){

var a = Array.prototype.slice(arguments)

return fn.apply(context,a.concat(out))

}

}

相关文章

网友评论

      本文标题:自主实现bind函数

      本文链接:https://www.haomeiwen.com/subject/njedvctx.html