[Javascript] Automate the process of flattening deeply nested arrays using ES2019's flat method
JavaScript The of 39 Using Process method
2023-09-14 09:00:49 时间
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] Link to Other Objects through the JavaScript Prototype Chain (Object.setPrototypeOf())
- [Javascript] Use a Pure RNG with the State ADT to Select an Element from State
- [Javascript Crocks] Recover from a Nothing with the `alt` method
- [Javascript] Logging Pretty-Printing Tabular Data to the Console
- [Javascript] The Array filter method
- [Jest] Restore the Original Implementation of a Mocked JavaScript Function with jest.spyOn
- [Javascript Crocks] Compose Functions for Reusability with the Maybe Type
- [WASM Rust] Use the js-sys Crate to Invoke Global APIs Available in Any JavaScript Environment
- [Javascript Crocks] Recover from a Nothing with the `alt` method
- [Javascript] Chaining the Array map and filter methods
- [Javascript] The Array forEach method
- JavaScript, ABAP和Scala里的尾递归(Tail Recursion)
- JavaScript自定义排序条件
- Atom编辑器折腾记_(15)JS代码片段补全(插件:javascript-snippets)
- 【华为OD机试 2023】 人数最多的站点/小火车最多人时所在园区站点(C++ Java JavaScript Python)
- JavaScript 虚拟键盘:Mindfusion JavaScript Keyboard