数组扁平化

flat()

let arr = [1,[2],[[3]]];
let arr1 = arr.flat(Infinity);
console.log(arr1);//[ 1, 2, 3 ]

JSON、replace()、split

let arr = [1,[2],[[3,21]]];
let arr1 = JSON.stringify(arr).replace(/(\[|\])/g,'').split(',');
console.log(arr1);//[ '1', '2', '3', '21' ]

JSON、replace

let arr = [1,[2],[[3,21]]];
let arr1 = JSON.parse('['+JSON.stringify(arr).replace(/(\[|\])/g,'')+']')
console.log(arr1);//[ 1, 2, 3, 21 ]