javascript initialize array code example
Example 1: javascript array
//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]);
}
Example 2: initialize javascript array variable
var arrayName = new Array();
var arrayName = new Array(Number length);
var arrayName = new Array(element1, element2, element3);
Example 3: how to initialize an array in javascript
var array_name = [item1, item2, ...];