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
Written by Emmanuel Bourgerie
Related protips
2 Responses
lol - what you're saying is replace: setTimeout(fn, 0) with setTimeout(fn, 1) --- defer simply sets 1ms delay
over 1 year ago
·
Lol
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#