array html code example

Example 1: MDN array length

const clothing = ['shoes', 'shirts', 'socks', 'sweaters'];

console.log(clothing.length);
// expected output: 4

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 ajouter une donnée à une list

let liste = ["azerty"]
liste.push('hello')
console.log(liste) //["azerty",'hello']

Example 4: javascript array

const arr = [1, 2, 3];

Example 5: tableau javascript

console.log(arr.0); // erreur de syntaxe

Tags:

Php Example