_.delay is incompatible with _.bind and _.bindAll.
Since _.delay calls its target function "func" with:
func.apply(func, args);
any object that was previously bound to func using _.bind or _.bindAll will not be "this" when func is called. Many other underscore functions have a special parameter for "this".. why not _.delay? Moreover, it seems totally useless to me to have "this" be a reference to the function itself. Why not just call func directly, instead of using "apply", and then not mess with the value of "this"? Am I missing something? Here is code for the _.delay function for reference purposes:
_.delay = function(func, wait) {
return setTimeout(function(){ return func.apply(func, args); }, wait);
};
_.delay is incompatible with _.bind and _.bindAll.
Since _.delay calls its target function "func" with:
func.apply(func, args);
any object that was previously bound to func using _.bind or _.bindAll will not be "this" when func is called. Many other underscore functions have a special parameter for "this".. why not _.delay? Moreover, it seems totally useless to me to have "this" be a reference to the function itself. Why not just call func directly, instead of using "apply", and then not mess with the value of "this"? Am I missing something? Here is code for the _.delay function for reference purposes:
_.delay = function(func, wait) {
return setTimeout(function(){ return func.apply(func, args); }, wait);
};