Intermediate
JavaScript
Q91 / 100
What is the difference between Array.prototype.flatMap() and map().flat()?
Correct! Well done.
Incorrect.
The correct answer is B) flatMap is equivalent to map().flat(1) but more efficient as it performs both operations in a single pass
B
Correct Answer
flatMap is equivalent to map().flat(1) but more efficient as it performs both operations in a single pass
Explanation
[1,2,3].flatMap(x => [x, x*2]) = [1,2,2,4,3,6] in one pass. .map().flat(1) does two iterations over the array.
Progress
91/100