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 函数特点,从第一个参数开始为函数参数,第二个为作用域,返回值是一个函数
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
网友评论