Get the App
SLTechnology News&Howtos  ›  Development  › 

How JavaScript flattens arrays

Shulou Source: shulou.com Published: 2022-06-01 04:39:24 09月22日 Update

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!

Tags: Flat array support content article value brother interest guy partner situation method more official edition knowledge type industry information information channel channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei vpn Shulou Tech Info macOS MariaDB