difference between : .forEach(), .map(), .filter().

difference between : .forEach(), .map(), .filter().

.forEach(), .map(), .filter() look realy similar but some point can change.

forEach:

is used to execute the same code on every element in an array but does not change the array and it returns undefined.

.map():

executes the same code on every element in an array and returns a new array with the updated elements.

.filter():

checks every element in an array to see if it meets a certain criteria and returns a new array with the elements that return only validating the criteria.


avatar

Patrick Arnaud

0
0

Laisser un commentaire