美文网首页
2018-08-16 bind

2018-08-16 bind

作者: aaagu1234 | 来源:发表于2018-08-16 17:02 被阅读2次

Function.prototype.bind = function(context){
var args = Array.prototype.slice(arguments, 1),
F = function(){},
self = this,
bound = function(){
var innerArgs = Array.prototype.slice.call(arguments);
var finalArgs = args.concat(innerArgs);
return self.apply((this instanceof F ? this : context), finalArgs);
};

F.prototype = self.prototype;
bound.prototype = new F();
retrun bound;
};

相关文章

网友评论

      本文标题:2018-08-16 bind

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