JS - Map-Filter-Reduce
JS - Map-Filter-Reduce
3 KILLER
ARRAY
METHODS
map( )
filter( )
Ajay Yadav
reduce( )
@ATechAjay
map( )
It accepts a callback function once for
each array element and returns a new
array.
Ajay Yadav
@ATechAjay
item - It's a required parameter, that is
the value of the current array item.
[
''IIndex
ndex10Square:
Square:400'
100',,
Ajay Yadav
@ATechAjay
item - It's a required parameter, that is
the value of the current array item.
Ajay Yadav
The filtered array will be nameStartsWithA variable.
@ATechAjay
reduce( )
Ajay Yadav
@ATechAjay
accumulator - It's a value of the previous
function call, or the InitialValue for the first call.
total = 0(InitialValue)
item = 10
InitialValue = 0
Ajay Yadav
@ATechAjay
In the above code, I’ve omitted the
InitialValue value, so the total variable is
initialised with 10 and the item variable is
initialised with 20.
Ajay Yadav
@ATechAjay