O'Reilly logo

JavaScript Recipes: A Problem-Solution Approach by Keith Cirkel, Russ Ferguson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Russ Ferguson and Keith Cirkel 2017
Russ Ferguson and Keith CirkelJavaScript Recipes10.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?

Problem

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

Solution

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

The Code

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

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required