Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How JavaScript flattens arrays

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report