-1
Given the array: [[[1,2,3],[4,5,6]]
As Transformer in: [1,2,3,4,5,6]
-1
Given the array: [[[1,2,3],[4,5,6]]
As Transformer in: [1,2,3,4,5,6]
4
you can do it this way.:
var matriz = [
['A', 'B', 'C'],
['D'],
['E', 'F'],
['G', 'H', 'I', 'J']
]
var array = matriz.reduce((list, sub) => list.concat(sub), [])
console.log(array)
2
var x = [["1", "2", "3"], ["3", "4", "5"]];
var y = x[0].concat(x[1]);
Browser other questions tagged javascript array
You are not signed in. Login or sign up in order to post.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat
– hkotsubo
I’m sure it’s duplicate, but I haven’t found the question that already exists.
– Victor Stafusa
@hkotsubo I suggest you post this in an answer. :)
– Victor Stafusa
@I think the duplicate that Anderson found already solves the problem. And the documentation that Linkei says is an experimental feature that may not work well on all browsers, so I don’t think it’s even worth an answer...
– hkotsubo