© Russ Ferguson and Keith Cirkel 2017

Russ Ferguson and Keith Cirkel, JavaScript Recipes, 10.1007/978-1-4302-6107-0_7

7. Working with Arrays

Russ Ferguson and Keith Cirkel2

(1)Ocean, New Jersey, USA

(2)London, UK

What Is an Array?


You want to hold on to information in sequence without creating multiple variables.


Use an array to store your data. An arrayis an object where you can store information in a list-like order.

The Code

Listing 7-1. Creating Array Literals and Instances of an Array Object
var arrayLit = []; //Array Literalvar arrayObj = new Array(); //Array instance using a constructor

How It Works

In all instances, you get an array with all the properties and methods of an array . Using the array literal is a quick way of building ...

Get JavaScript Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.