Chapter 3. Arrays

So far we’ve learned about numbers and strings, which are types of data that you can store and use in your programs. But numbers and strings are kind of boring. There’s not a lot that you can do with a string on its own. JavaScript lets you create and group together data in more interesting ways with arrays. An array is just a list of other JavaScript data values.

For example, if your friend asked you what your three favorite dinosaurs were, you could create an array with the names of those dinosaurs, in order:

var myTopThreeDinosaurs = ["T-Rex", "Velociraptor", "Stegosaurus"];

So instead of giving your friend three separate strings, you can just use the single array myTopThreeDinosaurs.

Why Should You Care About Arrays?

Get JavaScript for Kids 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.