How JavaScript flattens arrays
This article mainly introduces JavaScript how to flatten the array, the article introduces in great detail, has a certain reference value, interested friends must read it!
Flattened array
Array.prototype.flat has been added to ES 2019, which is supported by the latest official version of chrome 73.0.3683.103, not supported by the latest LTS 10.15.3 of node, and supported by the latest development version 11.13.0 of node. Here is a way to compare hack seen in the face of a brother of the Nuggets. Here you should pay attention to the type conversion according to the situation.
Const array = [1, [2, [3, 4], 5], 6, 7]; console.log (array.toString (). Split (',') .map (ele = > Number.parseInt (ele); / / > [1, 2, 3, 4, 5, 6, 7] are all the contents of the article "how JavaScript flattens arrays". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!