Learn
Arrays
Create an Array
An array is a data structure that can hold multiple values of different types. We can create an array using the following methods:
Method 1: Array Literal
The simplest way to create an array is by using array literal notation. Simply enclose the elements inside square brackets [] and separate them with commas.
Method 2: Array Constructor
Another way to create an array is by using the Array constructor.
Instructions
1.
Declare a variable named myArray
and assign it an empty array (array literal, without any elements).
Sign up to start coding
Already have an account?
Sign In
Course content