From the course: Learning the JavaScript Language

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Arrays

Arrays

- [Instructor] In this video we're going to talk about arrays which are a way of storing lists of data that preserve their order. We've already looked at objects which let you group data together, but there are some cases where you want to store say a list of things, and the order of those things actually matters. For example, let's say you want it to store a list of the days of the week, which of course appear in a certain order, or the months of the year, something like that. In cases like those, you'll want to use an array. So how do we make one? Let's create a variable and call it myArray. And instead of using curly braces, as we did with objects, we use square braces like this. That is the form of an array literal. And so now if I check the value of my array, I get back those same empty square braces. If I wanted to create a list of days of the week, I'll just add those two square braces again and now I'll fill…

Contents