JavaScript - Array Methods Flashcards
1
Q
Reduce method is the most ___ of all array operations
A
general
2
Q
Reduce returns
A
a single value
3
Q
Reduce accepts ____ as argument
A
callback function, called the reducer
4
Q
Arguments the reducer function takes…
A
Accumulator (acc) Current Value (cur) Current Index( idx) Source Array (src)
5
Q
Optional argument to the reducer
A
initialValue
6
Q
the first time the callback is called in reduce, accumulator and currentValue
A
if initialValue is provided, then accumulator = initialValue and currentValue = arr[0]
if no initialValue, then accumulator = arr[0], and currentValue = arr[1]
7
Q
It is _____ an initialValue
A
almost always safer to provide