Book Image

Learning Underscore.js

By : Alexandru Vasile Pop
Book Image

Learning Underscore.js

By: Alexandru Vasile Pop

Overview of this book

Table of Contents (14 chapters)
Learning Underscore.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Utility functions


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 the value parameter as a result

  • _.constant(value): This is closely related to _.identity() and creates a function that returns the value parameter when invoked

  • _.noop(): This creates a function that will always return undefined regardless of its invocation parameters

  • _.times(n, iteratee, [context]): This invokes the iteratee function n times and each time it is passing the current invocation index as parameter; the result is an array with all the iteratee invocation return values

  • _.random(min, max): This returns a random integer between min and max

  • _.mixin(object): This provides...