how can I convert [[" ", " ", " ", " ", " ", " ", " ", " ", " ", " "]] to
[" ", " ", " ", " ", " ", " ", " ", " ", " ", " "]?
I pushed an array to another, now I want to remove outer brackets from ii .
I’m looking for a method.
let ii :any[]=[];
const i = ' '.repeat(10) ;
const d = i.split('') ;
const aa=ii.push(d);
console.log(ii,ii.length);
console.log(d,d.length );
>Solution :
Modern javascript enviroments support the flat() method.
const flatData = [["a", "b", ["c", "d"]]].flat(2)
console.log(flatData)
// ["a", "b", "c", "d"]
The number you can optionally pass to flat() is the number of levels to flatten.