$ ./guess_the_languageProblem Solving — predict the output
Problem Solving — predict the output · medium · #67

What is the output?

console.log([1, [2, [3, [4]]]].flat());
  1. [1, 2, [3, [4]]]
  2. [1, 2, 3, [4]]
  3. [1, 2, 3, 4]
  4. [1, [2, [3, [4]]]]
flat() defaults to one level of depth.
Play Problem Solving ▸