Underscore has a set of miscellaneous functions that we will enumerate briefly in this section. Some of these functions will be explored in other chapters, and they will have a summary description followed by the chapter reference:
_.noConflict()
: This returns the Underscore object when the_
global variable is already in use_.identity(value)
: This is mainly used by Underscore internally to return thevalue
parameter as a result_.constant(value)
: This is closely related to_.identity()
and creates a function that returns thevalue
parameter when invoked_.noop()
: This creates a function that will always returnundefined
regardless of its invocation parameters_.times(n, iteratee, [context])
: This invokes theiteratee
functionn
times and each time it is passing the current invocation index as parameter; the result is an array with all theiteratee
invocation return values_.random(min, max)
: This returns a random integer betweenmin
andmax