JavaScript · Junior · Question 73 of 75
What does [1, [2, [3]]].flat() return?
- ✓Correct answer:
[1, 2, [3]] - 2
[1, 2, 3] - 3
[[1, 2, 3]]
Explanation
By default flat flattens one level. Pass a depth (flat(2)) or Infinity to flatten completely. flatMap maps then flattens one level.