Keep in mind that while arrays are technically objects, most individuals would refer to what you have as an array of arrays rather than an array of objects.
You cannot eliminate the outer layer unless you have multiple variables or properties to contain the outcome. Since your result consists of multiple things, you require a container for them (such as an array, an object, a Map
, etc.).
If you do possess variables or something similar to assign them to, you could utilize destructuring:
const arr = [[1,2,3],[1,2,4],[3,5,6],[2,4,5]];
const [a, b, c, d] = arr;
console.log(a); // [1, 2, 3]
Live Example:
const arr = [[1,2,3],[1,2,4],[3,5,6],[2,4,5]];
const [a, b, c, d] = arr;
console.log(a); // [1, 2, 3]
However, you must be aware of the exact number in advance. If it varies, you will need...a container such as an array, object, or Map
.