我有这一系列的对象

[{
    "A": "thisA",
    "B": "thisB",
    "C": "thisC"
}, {
    "A": "thatA",
    "B": "thatB",
    "C": "thatC"
}]


我试图将这种格式作为最终结果:[["thisA","thisB","thisC"], ["thatA","thisB","thatC"]]

我知道我们可以将map()函数与特定键(A,B,C)一起使用。

newarray = array.map(d => [d['A'], d['B'], d['C']])


但是我需要一个通用的函数来传输它而不使用键,因为数组的内容将不同,键也将不同。有什么好的解决办法吗?

最佳答案

const arr = [{
  "A": "thisA",
  "B": "thisB",
  "C": "thisC"
}, {
  "A": "thatA",
  "B": "thatB",
  "C": "thatC"
}]

const result = arr.map(Object.values)

console.log(result);

10-06 02:52