Map, Reduce & Filter Functions in JavaScript | Higher Order Functions

Published: 27 July 2020
on channel: Codingflag
1,700
51

In this video, I will show you everything you need to know about widely used and most popular higher order functions i.e. map, reduce and filter. You can simplify your javascript code by using map(), reduce() and filter() functions.
Map, reduce and filter all are array methods in javascript, each method iterates over an array and perform calculations.

Example used in video:

let a = [1,2,3,4,5];

Map:
a.map(function(number){ return number*10; });
// returns [10,20,30,40,50]

// Reduce
a.reduce(function(acc,value){ return acc+ val; });
// 15

//Filter
a.filter(function(number){ return number%2 == 0; });
// [2,4]