'Remove subarray of array and convert into objects?

I have an array of arrays which I have to convert into an array of objects:

[
  [
    {
      lable: "text",
      anotherValue: "anothervalue"
    }
  ], 
  [
    {
      lable: "text",
      anotherValue: "anothervalue"
    }
  ]
]

I need to convert this into:

[
  {
    lable: "text",
    anotherValue: "another value"
  }, 
  {
    lable: "text",
    anotherValue: "another value"
  }
]


Solution 1:[1]

You can do that using map. The function given to map as a parameter unpacks each subarray and replaces it by the object within.

a = [
  [{lable:'text',anotherValue:'anothervalue'}], 
  [{lable:'text',anotherValue:'anothervalue'}]
];

result = a.map((o) => o[0])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Florian Metzger-Noel