Skip to content

_.delay has no option to bind "this", and instead binds "this" to called function, which is useless #494

@dgbeck

Description

@dgbeck

_.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);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions