Array.prototype.flat()
1 | const arr1 = [0, 1, 2, [3, 4]]; |
reduce + concat + isArray + recursivity
1 | const arr = [1, 2, [3, 4, [5, 6]]]; |
ES3
1 | function flat(arr, depth) { |
1 | const arr1 = [0, 1, 2, [3, 4]]; |
1 | const arr = [1, 2, [3, 4, [5, 6]]]; |
1 | function flat(arr, depth) { |