Summary: Collections
Review what we learned about collections in JavaScript.
We'll cover the following
Key points
- Arrays are an ordered list of values.
- An array literal is written using square brackets containing comma-separated values—such as
[2,3,5,7]
. - Arrays can contain any type of value—even other arrays!
- The index is used to reference a specific item in an array. For example,
myArray[0]
refers to the first item inmyArray
. - Multi-dimensional arrays are arrays that contain other arrays.
- Arrays have many methods that can be used to add, remove and manipulate items in the array.
- The spread operator is used by placing an ellipsis of three dots in front of an array. It has the effect of taking all the values out of the array and listing them as separate values inside a new array.
Now that we’ve learned about different types of data and collections of data, it’s time to move on and learn how to control the flow of the program using logic, which we’ll cover in the next chapter. But first, we have a quiz and challenge!
Get hands-on with 1400+ tech skills courses.