多维数组扁平化一维数组
摘要:1.Array.prototype.flat() flat() 方法会按照一个可指定的深度递归遍历数组,并将所有元素与遍历到的子数组中的元素合并为一个新数组返回。 const arr = [0, 1, 2, [[[3, 4]]]]; console.log(arr.flat(2)); // [0,
阅读全文
posted @ 2021-07-28 23:06
posted @ 2021-07-28 23:06