...
/Manipulating Arrays in JavaScript
Manipulating Arrays in JavaScript
Learn how to create an Array, access one of its elements, and obtain its size.
We'll cover the following...
In JavaScript, an array is an object that has special properties.
Creating an array
Here’s how to create our list of movies in the form of an array.
Press + to interact
const movies = ["The Wolf of Wall Street", "Zootopia", "Babysitting"];
An array is created with a pair of square brackets []
. Everything within the brackets makes up the array. You can store different types of elements within an array, including strings, numbers, booleans and even objects.
Press + to interact
const elements = ["Hello", 7, { message: "Hi mom" }, true];
Since an array may contain multiple elements, it’s good to name the array plurally (for example,
movies
).
Obtaining an array’s size
The number of elements stored in an ...