convert array of object to array in javascript?

255 Views Asked by At

I have an array object like below:

[
    {
        first: "A",
        second: "B"
    },
    {
        first: "C",
        second: "D"
    },
]

and I want to convert to an array like this:

[
    [
        "A",
        "B"
    ],
    [
        "C",
        "D"
    ],
]

It would be highly appreciated if anyone can advise me!

1

There are 1 best solutions below

0
On BEST ANSWER

You could map the values.

const
    data = [{ first: "A", second: "B" }, { first: "C", second: "D" }],
    result = data.map(Object.values);

console.log(result);