how to initialize array in javascript code example
Example 1: list javascript
var fruits = ["Apple", "Banana", "Cherry"];
var books = [];
console.log(fruits[0])
fruits.push("Orange")
fruits[1]="Blueberry"
fruits.splice(0, 1)
fruits.splice(0, 2)
Example 2: javascript array
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
Example 3: initialize javascript array variable
var arrayName = new Array();
var arrayName = new Array(Number length);
var arrayName = new Array(element1, element2, element3);
Example 4: javacript array
[element0, element1, ..., elementN]
new Array(element0, element1[, ...[, elementN]])
new Array(arrayLength)
Example 5: how to initialize an array in javascript
var array_name = [item1, item2, ...];
Example 6: how to get create an array in javascript
let names = ['Michael', 'Adam', 'NetNinja'];
conosle.log(names[0]);