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.
- Inline HTML Helper - HTML Helpers in ASP.NET MVC
- ES6 | New String Methods
- ES6 | Array filter() Method
- ES6 | Array forEach() Method
- How to clone array in ES6 ?
- ES6 | Array
- ES6 | RegEx
- ES6 features and syntax
- ES6 | Promises
- Difference between node.js require and ES6 import and export
- Introduction to ES6
- Motivation to bring symbols in ES6
- ES6 | Math
- ES6 | Number
- ES6 | Dialog Boxes
- ES6 | Page Printing
- ES6 | Page Redirect
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.