Arrays
Declaration
let arr = new Array();
let arr = [];
// most time use [...]
let fruits = ["Apple", "Orange", "Plum"];
alert( fruits[0] ); // Apple
alert( fruits[1] ); // Orange
alert( fruits[2] ); // Plum
// replace
fruits[2] = 'Pear'; // now ["Apple", "Orange", "Pear"]
// add new one
fruits[3] = 'Lemon'; // now ["Apple", "Orange", "Pear", "Lemon"]
// length
let fruits = ["Apple", "Orange", "Plum"];
alert( fruits.length ); // 3
// store any type data
// mix of values
let arr = [ 'Apple', { name: 'John' }, true, function() { alert('hello'); } ];
// get the object at index 1 and then show its name
alert( arr[1].name ); // John
// get the function at index 3 and run it
arr[3](); // helloMethods pop/push, shift/unshift
Internals
Performance



Loops
A word about “length”
new Array()
Multidimensional arrays
toString
Last updated