The following code
function steamrollArray(arr) { // I\'m a steamroller, baby return arr.flat(); } steamrollArray([1, [2], [3, [[4]]]]);
Not sure if it is a valid answer however in my attemp to flat an array I employed the destructuring_assignment introduced in ES6.
// typeScriptArray:Array = new Array(); let concatArray = []; let firstArray = [1,2,3]; let secondArray = [2,3,4]; concatArray.push(...firstArray); concatArray.push(...secondArray); console.log(concatArray);
It works like a charm even though I'm not sure if any broswer compatibily issues may arise.