function arrMergeRecursive(arr, result) { for (var i = 0; i < arr.length; ++i) { Array.isArray(arr[i]) ? arrMergeRecursive(arr[i], result) : result.push(arr[i]); } return result; }