Array
Arrayspower most real-world JavaScript data work. Mastering the
core methods and loops is essential for exams, interviews, and
everyday productivity. Use this Cheat-Sheet to refresh quickly.
Core actions Order & Combine
push(...items) → Add items to the end sort() → Sort l
e eme nts as strings (alphabetical)
const a = [1]; [Link](2,3); // [1,2,3] ['b','a','c'].sort(); // ['a','b','c']
pop() → Rremove and return the last item reverse() → Reverse the array in place
const a = [1,2]; const last = [Link](); // 2 const a = [1,2,3]; [Link](); // [3,2,1]
unshift(...items) → Add items to the start join(separator) → Join elements into a string
const a = [2]; [Link](0,1); // [0,1,2] ['a','b','c'].join('-'); // 'a-b-c'
shift() → Remove and return the first item
Clonin g
const a = [1,2]; const first = [Link](); // 1
spread const copy = [...arr]
splice(start, deleteCount, ...items) → Remove/insert at an
index
slice const copy = [Link]()
const a = [1,2,3]; [Link](1,1,'x'); //
[1,'x',3]
[Link] const copy = [Link](arr)
concat(...arra ys) → Merge into a new array
concat const copy = [].concat(arr)
[1].concat([2,3]); // [1,2,3]
structuredClone onst deep = structuredClone(arr)
Transform & Aggregate
map(fn) → Transform each element → new array Note: spread/sli ce/[Link]/concat are shallow;
structure dClone is deep (for structured data).
m
[1,2,3]. ap(x = > x * 2); // [2, , ] 4 6
filter(fn) → Keep elements that pass the test
Brought to you by
4
[1,2,3, ].filter(x = > x % 2 === 0); // [2, ] 4
reduce(fn, initial) → Combine into one value
Creators of the
d
[1,2,3].re uce((s,x) = > s + x, 0); // 6
find(fn) → First matching element or d
un efine d
4 6
[1, , ].fin (x = d > x > 3); // 4 Learn more at [Link]/javascript
Array
Arrayspower most real-world JavaScript data work. Mastering the
core methods and loops is essential for exams, interviews, and
everyday productivity. Use this Cheat-Sheet to refresh quickly.
Core actions Order & Combine
push(...items) → Add items to the end sort() → Sort l
e eme nts as strings (alphabetical)
const a = [1]; [Link](2,3); // [1,2,3] ['b','a','c'].sort(); // ['a','b','c']
pop() → Rremove and return the last item reverse() → Reverse the array in place
const a = [1,2]; const last = [Link](); // 2 const a = [1,2,3]; [Link](); // [3,2,1]
unshift(...items) → Add items to the start join(separator) → Join elements into a string
const a = [2]; [Link](0,1); // [0,1,2] ['a','b','c'].join('-'); // 'a-b-c'
shift() → Remove and return the first item
Clonin g
const a = [1,2]; const first = [Link](); // 1
spread const copy = [...arr]
splice(start, deleteCount, ...items) → Remove/insert at an
index
slice const copy = [Link]()
const a = [1,2,3]; [Link](1,1,'x'); //
[1,'x',3]
[Link] const copy = [Link](arr)
concat(...arra ys) → Merge into a new array
concat const copy = [].concat(arr)
[1].concat([2,3]); // [1,2,3]
structuredClone onst deep = structuredClone(arr)
Transform & Aggregate
map(fn) → Transform each element → new array Note: spread/sli ce/[Link]/concat are shallow;
structure dClone is deep (for structured data).
m
[1,2,3]. ap(x = > x * 2); // [2, , ] 4 6
filter(fn) → Keep elements that pass the test
Brought to you by
4
[1,2,3, ].filter(x = > x % 2 === 0); // [2, ] 4
reduce(fn, initial) → Combine into one value
Creators of the
d
[1,2,3].re uce((s,x) = > s + x, 0); // 6
find(fn) → First matching element or d
un efine d
4 6
[1, , ].fin (x = d > x > 3); // 4 Learn more at [Link]/javascript