- Use
.map()
to mutate an array of objects - Articulate when it should be used over a 'for' or 'forEach' loop
In JavaScript we can always use for loops to iterate over arrays. However, arrays have many functions that can be performed on them that are more lexically clear. The .map
function is designed for when we want to mutate items in an array and return a new, mutated array.