JavaScript - Array Methods Flashcards

1
Q

Reduce method is the most ___ of all array operations

A

general

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

Reduce returns

A

a single value

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

Reduce accepts ____ as argument

A

callback function, called the reducer

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

Arguments the reducer function takes…

A
Accumulator (acc)
Current Value (cur)
Current Index( idx)
Source Array (src)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Optional argument to the reducer

A

initialValue

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

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

It is _____ an initialValue

A

almost always safer to provide

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