array in array js code example

Example 1: javascript element in array

var fruits = ["Banana", "Orange", "Apple", "Mango"];

var n = fruits.includes("Mango");

Example 2: 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 3: array of objects javascript

var widgetTemplats = [
    {
        name: 'compass',
        LocX: 35,
        LocY: 312
    },
    {
        name: 'another',
        LocX: 52,
        LocY: 32
    }
]

Example 4: javascript to array

Array.from("Hello"); // ["H", "e", "l", "l", "o"]

Example 5: javacript array

[element0, element1, ..., elementN]

new Array(element0, element1[, ...[, elementN]])
new Array(arrayLength)

Example 6: create array with number js

var foo = new Array(45); // create an empty array with length 45

Tags:

Php Example