Chapter 6

Using Arrays

IN THIS CHAPTER

Bullet Creating, accessing, and modifying arrays

Bullet Removing array elements

Bullet Programming and looping with array methods

Bullet Destructuring and spreading arrays

“I am large. I contain multitudes.”

—WALT WHITMAN

Most of the data I describe how to work with earlier in this book is in the form of simple variables and constants that store a single value. However, it's common in programming, and in life, to need to store lists of related items under a single name. Think about the following common lists that many people use daily:

  • Mailing lists and contacts
  • Grocery lists
  • To-do lists
  • Lists of favorite songs
  • The list of items on an invoice or a receipt
  • The list of chapters in a book

In each case, without the ability to collect individual pieces of data into a list, you'd just have sticky notes scattered all over the place and in no particular order (a bit like my desk).

Think for a moment about your favorite apps and websites. Whether it's a blog, a social media site such as Twitter or Instagram, or your daily run log app, a large part of the app is dedicated to ...

Get JavaScript All-in-One For Dummies 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.