I have an array object like below:
JavaScript
x
11
11
1
[
2
{
3
first: "A",
4
second: "B"
5
},
6
{
7
first: "C",
8
second: "D"
9
},
10
]
11
and I want to convert to an array like this:
JavaScript
1
11
11
1
[
2
[
3
"A",
4
"B"
5
],
6
[
7
"C",
8
"D"
9
],
10
]
11
It would be highly appreciated if anyone can advise me!😊
Advertisement
Answer
You could map the values.
JavaScript
1
5
1
const
2
data = [{ first: "A", second: "B" }, { first: "C", second: "D" }],
3
result = data.map(Object.values);
4
5
console.log(result);