New Array Methods Flashcards
1
Q
What is Array.prototype.filter useful for?
A
Used for filtering arrays.
Array.filter(callback function returning BOOLEAN)
Array.filter(number => number % 2 === 0)
2
Q
What is Array.prototype.map useful for?
A
Used to transform exisiting arrays.
Array.map(callback function returning value)
Array.map(number => number *2)
3
Q
What is Array.prototype.reduce useful for?
A
reduces the array (accumulate) (accumulator, currentValue) => { return accumulator + currentValue; } Array.reduce(callback function, initialValue)