LearnFrenzy
Sign in Take a free test

Array Methods · Array Methods MCQ · Question 8

Default depth of flat Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

What is [1, [2, [3, [4]]]].flat()?

  • A [1, 2, [3, [4]]] Correct
  • B [1, 2, 3, 4]
  • C [1, [2, [3, [4]]]]
  • D [[1], [2], [3], [4]]
Correct Answer: Option A

flat() removes one level of nesting by default. flat(Infinity) flattens completely.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links