Back to Blog
Tutorial2025-01-18

Essential JavaScript Array Methods You Should Know

Learn the most commonly used array methods in JavaScript with practical examples.

map() - Transform Elements

Creates a new array by transforming each element:

const numbers = [1, 2, 3]; const doubled = numbers.map(n => n * 2); // [2, 4, 6]

filter() - Select Elements

Creates a new array with elements that pass a test:

const numbers = [1, 2, 3, 4, 5]; const evens = numbers.filter(n => n % 2 === 0); // [2, 4]

reduce() - Accumulate Values

Reduces array to a single value:

const numbers = [1, 2, 3, 4]; const sum = numbers.reduce((acc, n) => acc + n, 0); // 10

find() - Find First Match

Returns the first element that passes a test:

const users = [{name: 'John'}, {name: 'Jane'}]; const jane = users.find(u => u.name === 'Jane');

forEach() - Iterate

Executes a function for each element:

[1, 2, 3].forEach(n => console.log(n));

some() and every()

Check if some or all elements pass a test:

[1, 2, 3].some(n => n > 2); // true [1, 2, 3].every(n => n > 0); // true