[Vuejs]-How to fetch the all objects from the array of array?

0👍

Just uses the flat method.

The flat() method creates a new array with all sub-array elements
concatenated into it recursively up to the specified depth.

const array1 = [
  [{
      id: 1,
      name: "test1",
    },
    {
      id: 2,
      name: "test2",
    },
    {
      id: 3,
      name: "test3",
    },
  ],
  [{
      id: 4,
      name: "test4",
    },
    {
      id: 5,
      name: "test5",
    },
    {
      id: 6,
      name: "test6",
    },
  ],
  [{
      id: 7,
      name: "test7",
    },
    {
      id: 8,
      name: "test8",
    },
    {
      id: 9,
      name: "test9",
    },
  ],
];
let result = array1.flat()
console.log(result);

Leave a comment