how to create array in javascript

JavaScript
// Don't need to provide elements directly, but you can

// FIRST OPTION
var myArray = new Array(/*elements1, elements2*/);

// SECOND OPTION
var mySecondArray = [/*element1, element2*/];//create an array like so:
var colors = ["red","blue","green"];

//you can loop through an array like this:
for (var i = 0; i < colors.length; i++) {
    console.log(colors[i]);
}//Im using a let type variable for the example because it's what i reccomend

let exampleArray = ["Example", "Lorem Ispum Dolor", "I think you've got it"]

//Here's how you select a single object in the list

exampleArray[1] 

/*In Javascript the arrays start counting at 0 which means i selected the 2nd
object in the list(Lorem Ispum Dolor) so if i wanna select the first array i
must type*/

exampleArray[0]

/*Now let's say you want to display it on the console, like let's say you are 
coding in Node.js and you wanna see the value of the array.
P.S: In the example im gonna show all the values of the array.*/

console.log(exampleArray[0, 1, 2]let fruits = ['Apple', 'Banana']

console.log(fruits.length)
// 2
/* 
	Array class is a global object that is used
    in the construction of arrays
    
    See - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
*/
let array_1 = new Array(2);
	arr.push("James");
	arr.push("Fred");

let array_2 = ["James", "Fred"];Array.from("Hello"); // ["H", "e", "l", "l", "o"]
Source

Also in JavaScript: