Array.prototype.flatintermediateconst arr = [1, [2, [3, [4]]]]
arr.flat(Infinity) // β [1, 2, 3, 4]Pass Infinity to flat() to fully flatten an arbitrarily deeply nested array.
Passing Infinity as the depth argument to flat() flattens all levels of nesting, no matter how deep.
Challenge: Implement flatDeep(arr) that flattens all nested arrays using arr.flat(Infinity).
flatDeep([1, [2, [3, [4]]]]) // β [1, 2, 3, 4]
flatDeep([[[[1]]]]) // β [1]