forEach(): The forEach() function is used to iterates through all the entries of the array.
Example: To find the sum of all the numbers in an array of numbers.
map(): The map() method is used to iterate through all the entries of the array, modifies them and returns a new array but the old array is not manipulated.
Example: To multiply each number of the array by 2 and generate a new array.
2, 4, 6, 8, 10
Example: The map() method can also be used to extract attributes from an array of objects and store it in another array.
2, 4, 6
filter(): The filter() method is used to iterate through all the entries of the array and filters out required entities into another array.
Example: To filter all objects where flag is 1.
flag:1, a:1 flag:1, a:3
find(): The find() method is used to iterate through all the entries of the array and returns the record matching with a particular condition.
Example: To find a object where flag is 0.
Note: The filter() method returns an array of objects and find() method returns a single object.