Array Iterators Flashcards

(13 cards)

1
Q

Returns an iterator that contains key/value pairs of each index in the array

A

array.entries()

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

Tests whether all elements in the array pass the test implemented by the provided function

A

array.every()

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

Creates a new array with all elements that pass the test implemented by the provided function.

A

array.filter() (immutable - creates a new array)

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

Returns the first element in an array that satisfies the provided testing function.

A

array.find()

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

Return the index of the first element in an array that satisfies the provided testing function.

A

array.findIndex()

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

Iterates the array in reverse order and returns the value of the first element that satisfies the provided testing function.

A

array.findLast()

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

Iterates the array in reverse order and returns the index of the first element that satisfies the provided testing function.

A

array.findLastIndex()

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

Apply callback and flatten results 1 level

A

array.flatMap()

const arr1 = [1, 2, 1];

const result = arr1.flatMap((num) => (num === 2 ? [2, 2] : 1));
// Expected output: Array [1, 2, 2, 1]

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

Execute a provided function once for each array element.

A

array.forEach()

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

When you want to transform elements in an array.

A

array.map()

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

When you want derive a single value from multiple elements in an array.

A

array.reduce()

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

Derive a single value from multiple elements in an array from right to left.

A

array.reduceRight()

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

Test that at least one element of the array passes the test implemented by the given function

A

array.some()

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