Skip to content

Instantly share code, notes, and snippets.

@junajan junajan/flatten.js
Created Nov 12, 2019

Embed
What would you like to do?
const arr = [{
values: [1, 2]
}, {
values: [3, 4]
}];
const c = arr
.map((obj) => obj.values)
.reduce(((all, arr) => [...all, ...arr]), []);
console.log(c)
// > [ 1, 2, 3, 4 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.