array in array javascript 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: javascript array

const arr = [1, 2, 3];

Example 4: array javascript

var familly = []; //no familly :(
var familly = new Array() // uncommon
var familly = [Talel, Wafa, Eline, True, 4];
console.log(familly[0]) //Talel
familly[0] + "<3" + familly[1] //Talel <3 Wafa
familly[3] = "Amir"; //New coming member in the family

Example 5: create array with number js

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

Example 6: how to make a array in javascript

//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]