← Lesson
BitWithBite
JavaScript · Quick Reference

Lesson 8 — Arrays Cheat Sheet

JavaScript
In one line: An array is an ordered list of values. Each value is called an element, and each element has a numeric index starting at 0.

Key Ideas

1Creating Arrays. An array is an ordered list of values. Each value is called an element, and each element has a numeric index starting at 0.
2Mutating Methods. These methods modify the original array. Use them when you intentionally want to change the array in place.
3Iteration Methods. These are the most powerful array tools in JavaScript. They let you transform, filter, and reduce data without writing manual loops.

Code Examples

// 1. Array literal (most common) const fruits = ['apple', 'banana', 'cherry']; // 2. Array constructor const nums = new Array(1, 2, 3, 4, 5); // 3. Array.from() — convert iterable to array const letters = Array.from('hello'); // ['h','e','l','l'...
const colors = ['red', 'green', 'blue', 'yellow']; // Access by index (0-based) colors[0]; // 'red' colors[2]; // 'blue' colors[colors.length - 1]; // 'yellow' — last element // Modern: .at() method — supports negative indexing!...
const arr = [1, 2, 3]; // push — add to END, returns new length arr.push(4, 5); // arr = [1,2,3,4,5] // pop — remove from END, returns removed item const last = arr.pop(); // last=5, arr=[1,2,3,4] // unshift — add to BEGINNING arr.unshift...