These functions often aren't very complex, but you can use them to clearly communicate what your code is doing.
list[list.length - 1]
This is done by setting a timeout with a wait time of 0 milliseconds:
By contrast, Underscore has a defer method - all it does is give a more meaningful name to "wait for 0 milliseconds":
Underscore is full of handy methods like these. Here are three more of them:
_.contains(list, item)instead of
list.indexOf(item) !== -1.
value === void(0)
True, you could write your own project-specific helper functions instead - but why bother when Underscore is well tested and only 6kb to download? Plus, knowledge of Underscore is transferable between projects and companies, which makes onboarding new developers easier.