Skip to content
Guest
← All References
JavaScript Baseline Widely Available

Array Methods

Most frequently used immutable JavaScript array transformation and lookup methods.

arr.map(fn), arr.filter(fn), arr.reduce(fn, init), arr.find(fn)
MethodReturnsMutates Original?Example
.map(fn)New array of transformed itemsNo[1, 2].map(x => x * 2) → [2, 4]
.filter(fn)New array of matching itemsNo[1, 2, 3].filter(x => x > 1) → [2, 3]
.find(fn)First matching item or undefinedNo[1, 2, 3].find(x => x > 1) → 2
.reduce(fn, init)Single accumulated valueNo[1, 2, 3].reduce((a, b) => a + b, 0) → 6

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind