background:
Multidimensional array expansion
question:
var arr = [1,2,[3,4,[5,6,[7,8],9],10]];
function fn(arr){
return [].concat(arr.map(d=> Array.isArray(d)?fn(d):d))//(3)[1, 2, Array(4)]
// return [].concat(...arr.map(a=> Array.isArray(a)? fn(a):a))//(10)[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}
What"s wrong with the first way of writing? Why the result is not ideal how to break a sentence in the second way