Arrays in javascript

Arrays are ordered collections of values. Common methods include push/pop, shift/unshift, forEach, map, filter, reduce, find, some, and every. Arrays are zero-indexed and are objects under the hood.

Example

const nums = [1, 2, 3, 4];

nums.push(5);           // [1,2,3,4,5]
nums.pop();             // [1,2,3,4]

nums.forEach(n => console.log(n)); // 1 2 3 4

const doubled = nums.map(n => n * 2);        // [2, 4, 6, 8]
const evens   = nums.filter(n => n % 2 === 0); // [2, 4]
const firstGt2 = nums.find(n => n > 2);      // 3
const allPos   = nums.every(n => n > 0);     // true
const hasEven  = nums.some(n => n % 2 === 0); // true

const sum = nums.reduce((acc, n) => acc + n, 0); // 10

These are the core array methods you use daily: push/pop to change length, forEach to iterate, map/filter to transform/filter, find to get a single match, and reduce to fold into one value.