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

Arrays


The Underscore functions targeting collections worked with array-like objects or object properties. In this section, we will look into more specific functions that work with the Array object or with array-like objects such as the arguments variable that is available in any JavaScript function body.

First, we will expand the sample data we used in the previous chapter by adding an array of client objects for our bicycle rental universe. Each client has rented at least one bicycle and has a registered date property and a preferredBike property holding the name of an existing bicycle. The client object has other standard properties such as name, gender, and email. We can use a website such as www.json-generator.com to define and randomly generate the required JSON data in a larger quantity that is suitable for more involved examples. A sample of such a client object is as follows:

{
  "id": 4,
  "name": "Virgie Glenn",
  "gender": "female",
  "company": "SPHERIX",
  "email": "virgieglenn...