[Solved] How to remove second square brackets from an array using JavaScript?


You can use Array.flat() to flatten sub-arrays:

const data = [
  [
    {id: 1},
    {id: 2}
  ],
  [
    {id: 3},
    {id: 4}
  ]
];

const newData = data.flat();
console.log(newData);

If Array.flat() is not supported, you can spread the array into Array.concat():

const data = [
  [
    {id: 1},
    {id: 2}
  ],
  [
    {id: 3},
    {id: 4}
  ]
];

const newData = [].concat(...data);
console.log(newData);

0

solved How to remove second square brackets from an array using JavaScript?