how to create an array in javascript

JavaScript
// Initializing while declaring 
// Creates an array having elements 10, 20, 30, 40, 50 
var house = new Array(10, 20, 30, 40, 50); 
  
//Creates an array of 5 undefined elements 
var house1 = new Array(5); 
  
//Creates an array with element 1BHK 
var home = new Array("!BHK"); 
let fruits = ['Apple', 'Banana']

console.log(fruits.length)
// 2
var cars = ["Saab", "Volvo", "BMW"];
 var myArray = [ "Jack", "Sawyer", "John", "Desmond" ];//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]);
}//single array declaration
var car1 = "Saab";
var car2 = "Volvo";
var car3 = "BMW";

//one line
var cars = ["Toyota", "Jeep", "BMW"];

//multiple lines
var cars = [
 "Toyota",
 "Jeep",
 "BMW"
];
Source

Also in JavaScript: