DEV Community

Cover image for Array Iterations in JavaScript
QUBE
QUBE

Posted on

Array Iterations in JavaScript

Array forEach()

  • The forEach() method calls a function (a callback function) once for each array element.

Array map()

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

  • The map() method does not execute the function for array elements without values.

  • The map() method does not change the original array.

Array flatMap()

  • The flatMap() method first maps all elements of an array and then creates a new array by flattening the array.

Array filter()

  • The filter() method creates a new array with array elements that pass a test.

Array reduce()

  • The reduce() method runs a function on each array element to produce a single value.

Array reduceRight()

  • The reduceRight() works from right-to-left in the array. See also reduce().

Array every()

  • The every() method checks if all array values pass a test.

Array some()

  • The some() method checks if some array values pass a test.

Array Spread (...)

  • The ... operator expands an array into individual elements.

TBD(Array from(),Array keys(),Array entries(),Array with() & Array Rest (...)).

References:

Top comments (0)