Open this example in the interactive library
Source code
const data = [1, [2, [3, 4]]];
console.log(data.flat(Infinity));
Sample output
[ 1, 2, 3, 4 ]

Flatten nested arrays. A self-contained example using the JavaScript runtime.
Open this example in the interactive library
const data = [1, [2, [3, 4]]];
console.log(data.flat(Infinity));
[ 1, 2, 3, 4 ]