JavaScript interview: Implement Array.prototype.flat
easy
arrays
recursion
Write flatten(arr, depth = 1) without using .flat(). Nested arrays are spread into the result up to depth levels. depth = Infinity flattens everything.
Your code
Runs in a Web Worker in your browser. Tests use real timers, so a run takes a second or two.