JavaScript array is a special data structure to store ordered values. It can be written as values, or items, separated by commas inside of square brackets:

[item1, item2, item3]


Using an array literal is the easiest way to create a JavaScript array.

We can declare an empty array:

let e = [];

We can supply initial elements in the brackets:

let fruits = ["Apple", "Orange", "Banana"];
let myArray = [2, 4, 6, 8];
let studentRecords = ['Bella', 'Math', 98];

An array can store elements of different types like in the last example.

Arrays have some characteristics similar to strings, including indexing, looping, the length property, and addition and multiplication operations.

results matching ""

    No results matching ""