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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Array.prototype.reduce useful for?

A
reduces the array (accumulate)
(accumulator, currentValue) => {
  return accumulator + currentValue;
}
Array.reduce(callback function, initialValue)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly