Code sample
Flatten array of arrays with JavaScript
const arrays = [[1], ["2"], [3]];
const merged = [].concat(...arrays);
console.log(merged); // [ 1, '2', 3 ]
Pre ES6:
var merged = [].concat.apply([], arrays);
Similar articles
- Quickly mapping an array of URLs to responses with JavaScript async/await and Promise.all
- Notes from learning Go - the basics
- Exception order when awaiting multiple async tasks in C#
- Quickly creating and mapping an array in JavaScript
- The DRY obsession
- Fix for weird looking Google Maps controls and overlays
- Detecting mouse and keyboard input with .NET
- jQuery developers, where is the progressive enhancement?