To initialize an array in JavaScript, you can use array literals or the Array constructor.
In this example,
numbers
using array literals with integer values.let numbers = [1, 2, 3, 4, 5];
console.log(numbers);
[ 1, 2, 3, 4, 5 ]
In this example,
fruits
using the Array constructor with string values.let fruits = new Array('Apple', 'Banana', 'Orange');
console.log(fruits);
[ 'Apple', 'Banana', 'Orange' ]
In this tutorial, we learned How to Initialize an Array in JavaScript language with well detailed examples.