Skip to content Skip to sidebar Skip to footer

Underscore Debounce With Arguments

Suppose I have this event handler: var mousewheel = function (e) { /* blah */ }; But, I want to debounce it. So I do this, which works as expected: var mousewheelDebounced = _.deb

Solution 1:

On each mousewheel event (which occurs very often) you create a new version of debounce function. This function has no history, and doesn't know that on previous event there was another one created. So it just runs. That's why you should go with the first version.


Post a Comment for "Underscore Debounce With Arguments"