我尝试使用Array.includes,但是此代码返回false:
const data = [
{
date: "2019-11-04",
transactionTypes: {
type1: [
{ irrelevantObject1: "irrelevantObject1" },
{ irrelevantObject2: "irrelevantObject2" },
{ irrelevantObject3: "irrelevantObject3" },
{ irrelevantObject4: "irrelevantObject4" }
],
type2: [
{ irrelevantObject1: "irrelevantObject1" },
{ irrelevantObject2: "irrelevantObject2" },
{ irrelevantObject3: "irrelevantObject3" }
]
}
}
];
const result = data.map(o => ({
...o,
transactionTypes: Object.entries(o.transactionTypes).map(([k, arr]) => ({
[k]: arr.length
}))
}));
console.log(result);
有人知道我可以代替什么吗?