数组如下
[
{checked: true, index: 0}
{checked: true, index: 1}
{checked: true, index: 2}
{checked: true, index: 3}
{checked: true, index: 4}
{checked: true, index: 5}
{checked: true, index: 1}
]
输出结果为
[checked:true, index: 1]
数组如下
[
{checked: true, index: 0}
{checked: true, index: 1}
{checked: true, index: 2}
{checked: true, index: 3}
{checked: true, index: 4}
{checked: true, index: 5}
{checked: true, index: 1}
]
输出结果为
[checked:true, index: 1]
const a = [
{checked: true, index: 0},
{checked: true, index: 1},
{checked: true, index: 2},
{checked: true, index: 3},
{checked: true, index: 4},
{checked: true, index: 5},
{checked: true, index: 1}
]
const result = Array.from(a.reduce((m, t) => m.set(t.place, t), new Map()).values());
13 回答12.8k 阅读
7 回答1.9k 阅读
3 回答1.1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
6 回答873 阅读✓ 已解决
6 回答1k 阅读
2 回答1.3k 阅读✓ 已解决