三. Array.protoype.flag 与 flatMap
// flat 将多维数组转为地位数组
const arr = [1,2,3,4,[5,6]];
console.log(arr); //[1,2,3,4,5,6]
cosnt arr1 = [1,2,3,4,[5,6,[7,8]]];
console.log(arr1.flat(2)); //[1,2,3,4,5,6,7,8]
// flatMap 将低位数组转为多维数组
const arr2 = [1,2,3,4];
const result = arr2.map(item=> [item*10]);
console.log(result); // [[10],[20],[30],[40]]
const result2 = arr2.flatMap(item=> [item*10]);
console.log(result2); // [10,20,30,40]