aje5hq
Last Updated: July 30, 2016
·
4.328K
· manudwarf

underscorejs - use defer instead of setTimeout

We often have dirty 0ms setTimeout in our code. Although it perfectly works, it feels wrong to do it this way, that's why you can use _.defer() to do it :

_.defer(function() {
    console.log("Do something");
});

More at the underscore API: http://underscorejs.org/#defer

2 Responses
Add your response

17331

lol - what you're saying is replace: setTimeout(fn, 0) with setTimeout(fn, 1) --- defer simply sets 1ms delay

over 1 year ago ·
28032

Lol

over 1 year ago ·