Underscore.js is a lightweight JavaScript library and not a complete framework that was written by Jeremy Ashkenas that provides utility functions for a variety of use cases in our day-to-day common programming tasks.
Underscore provides a number of functions that can be applied to the elements. These include the ability to bind a function to an object, wrap a function inside another function, memorize a given function by caching the result computed by the function, apply partially a function by filling in any number of its arguments, without changing its dynamic value and many other wonderful functionalities.
The complete reference for underscore functions is provided below:
Function |
Description |
---|---|
_.bind() | It is used to bind a function to an object. |
_.bindAll() | It is used to bind the number of methods on the object. |
_.partial() | It applies a function by filling in any number of its arguments, without changing its dynamic value. |
_.memoize() | It is used to memorize a given function by caching the result computed by the function. |
_.delay() | It executes the mentioned function in its argument after waiting for the specified milliseconds. |
_.defer() | It is used to invoke/call a function until the current call stack is cleared. |
_.throttle() | It creates a throttled function that can only call the func parameter once per every wait milliseconds. |
_.debounce() | It is used to create a debounced function. |
_.once() | It is used in conditions where we want a particular function to be executed only a single time. |
_.after() | It creates a wrapper of function which doesn’t do anything in the start but from the stated count it starts calling the function. |
_.before() | It is used to call a particular function a particular number of times. |
_.wrap() | It is used to wrap a function inside other function. |
_.negate() | It finds a new negated version of the stated predicate function. |
_.compose() | It returns the composition of the list of functions. |
_.restArguments() | It can receive all the arguments from and beyond the stated startIndex that is collected into a single array. |