map(), filter(), forEach() array methods in Javascript

Manikandan K - Apr 19 '22 - - Dev Community

1. forEach

  • forEach method executes a provided function each array element only once in ascending index order.
  • ForEach method is not execute empty elements.
  • ForEach method is not return any value. Its return 'undefined'.

Image description

2. array.map()

  • map method creates new array from calling a function for each array element.
  • map method is not execute an empty elements.
  • map method returns new array results of function for each array elements.
  • map method not affect original array.

Image description

3. array.filter()

  • 1. filter method creates a new array with all array elements that pass the test condition by provided function.
  • 2. If condition fails it return an empty array.
  • 3. filter method not affect original array.

Image description

. . . . . . . . . . . . . . . . . . . .