Arrays

Basic

const arr = [2, 5, 6];
// declare

arr[2];
// index

Methods


arr.length;
// returns 3

arr.push(4);
// 4 is pushed to the end of arr

arr.pop();
// removes the last element of arr

// push and pop work with const

arr.shift();
// removes the first element of arr

arr.unshift('start');
// adds a new element to the start of arr

arr.splice(6, 5, 'know');
// replaces all 5 elements after arr[6] with one arr[7] with value 'know'

arr.join('')
// shoves all elements into a string, () specifies what goes between each element