all-of-frontend/1.js
2021-03-16 10:43:42 +08:00

26 lines
487 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const dedup = (data, getKey = () => {} ) => {
// todo
}
let data = [
{ id: 1, v: 1 },
{ id: 2, v: 2 },
{ id: 1, v: 2 },
];
// 以 id 作为排重 key执行函数得到结果
// data = [
// { id: 1, v: 1 },
// { id: 2, v: 2 },
// ];
let data1 = [
{ id: 1, v: 1, id1: 1 },
{ id: 2, v: 2, id1: 2 },
{ id: 1, v: 2, id1: 1 },
]
// 以 id 和 id1 作为排重 key执行函数得到结果
// data1 = [
// { id: 1, v: 1, id1: 1 },
// { id: 2, v: 2, id1: 2 },
// ];