Returns a new array with all nested arrays recursively flattened into a
single-level array. Holes in sparse arrays are treated as undefined.
The input array is not mutated.
A new array flattened to a single level. 扁平化为单层后的新数组
Remarks
Array.prototype.flat() only covers one level by default; this function
flattens to any depth. O(n) time complexity where n is the total number of
elements at all levels.
Flattens an array to an arbitrary depth.
Returns a new array with all nested arrays recursively flattened into a single-level array. Holes in sparse arrays are treated as
undefined. The input array is not mutated.将数组任意深度地扁平化。
返回一个新数组,所有嵌套数组都会被递归展开为单层数组。稀疏数组中的空洞按
undefined处理。 不会修改输入数组。