Utilizor
Contact Us

map, filter, reduce

Functional array methods.

map, filter, reduce

map()

map() creates a new array by performing a function on each array element.

filter()

filter() creates a new array with all array elements that pass a test.

reduce()

reduce() runs a function on each array element to produce (reduce it to) a single value.

Example

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