先贴代码:
var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
if (!(callingContext instanceof boundFunc))
return sourceFunc.apply(context, args);
var self = baseCreate(sourceFunc.prototype);
var result = sourceFunc.apply(self, args);
if (_.isObject(result))
return result;
return self;
};
// Create a function bound to a given object (assigning this
, and arguments,
// optionally). Delegates to ECMAScript 5's native Function.bind
if
// available.
.bind = function(func, context) {
if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
if (!.isFunction(func)) throw new TypeError('Bind must be called on a function');
var args = slice.call(arguments, 2);
var bound = function() {
return executeBound(func, bound, context, this, args.concat(slice.call(arguments)));
};
return bound;
};
想问下,executeBound(func, bound, context, this, args.concat(slice.call(arguments)))这个里面的this是否就是指代调用_.bound的对象,然后后面为何要做(!(callingContext instanceof boundFunc))这个判断,网上查了好久,没查出来,请高手指导下,非常感谢