-3
(2) [Array(2), Array(1)]
0: Array(2)
0: {_id: '61cd4544264332414823198d', action: 'checkin', time: '2021-12-30T05:36:04.143Z'}
1: {_id: '61cd60713082f35340af2a87', action: 'checkout', time: '2021-12-30T07:32:01.986Z'}
length: 2
[[Prototype]]: Array(0)
1: Array(1)
0: {_id: '61cd455a26433241482319a5', action: 'checkin', time: '2021-12-30T05:36:26.346Z'}
length: 1
[[Prototype]]: Array(0)
length: 2
[[Prototype]]: Array(0)

I want all objects into one array like :

[
0: {_id: '61cd4544264332414823198d', action: 'checkin', time: '2021-12-30T05:36:04.143Z'}
1: {_id: '61cd60713082f35340af2a87', action: 'checkout', time: '2021-12-30T07:32:01.986Z'}
2: {_id: '61cd455a26433241482319a5', action: 'checkin', time: '2021-12-30T05:36:26.346Z'}
]
1
  • 1
    Try .flat() Commented Dec 30, 2021 at 11:15

1 Answer 1

0

You can try this:

const input = [[{_id: '61cd4544264332414823198d', action: 'checkin', time: '2021-12-30T05:36:04.143Z'},
{_id: '61cd60713082f35340af2a87', action: 'checkout', time: '2021-12-30T07:32:01.986Z'}], [{_id: '61cd455a26433241482319a5', action: 'checkin', time: '2021-12-30T05:36:26.346Z'}]];

console.log(input.flat());
// output: > Array [Object { _id: "61cd4544264332414823198d", action: "checkin", time: "2021-12-30T05:36:04.143Z" }, Object { _id: "61cd60713082f35340af2a87", action: "checkout", time: "2021-12-30T07:32:01.986Z" }, Object { _id: "61cd455a26433241482319a5", action: "checkin", time: "2021-12-30T05:36:26.346Z" }]

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.