码迷,mamicode.com
首页 > 编程语言 > 详细

[Javascript] Automate the process of flattening deeply nested arrays using ES2019's flat method

时间:2019-02-07 17:49:23      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:ted   rip   The   asc   pre   class   java   color   reg   

Among the features introduced to the language of JavaScript in ES2019 is Array.prototype.flat. In this lesson we‘ll see just how easy the flat method makes the process of unboxing arrays regardless of how deeply nested they may be.

 

Deep flatten:

var arr2 = [1, 2, [3, 4, [5, 6]]];
console.log(arr2.flat(Infinity)); // [1, 2, 3, 4, 5, 6]

 

[Javascript] Automate the process of flattening deeply nested arrays using ES2019's flat method

标签:ted   rip   The   asc   pre   class   java   color   reg   

原文地址:https://www.cnblogs.com/Answer1215/p/10354930.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!