The Developer's Main Tools
Modern JS is 50% working with these methods.
1. forEach (Simple iteration)
["Bilbo", "Gandalf"].forEach(alert);
2. map (Creating a new array)
Applies a function to each element and returns an array of results.
let entryLen = ["Bilbo", "Gandalf"].map(item => item.length);
// [5, 7]
3. filter (Data cleansing)
Returns an array of elements that passed the test.
let users = [{id: 1, admin: true}, {id: 2, admin: false}];
let admins = users.filter(user => user.admin);
Important
The reduce method is the most powerful. It allows you to " fold " an array into a single value (e.g., calculating the sum of all prices in a cart).