const array = ['a', 'b', 'c']; // 数据源
function checkRepeat(array) {
const temp = {}; // 临时表
const repeat = {}; // 重复的数据
for (const i of array) {
if (temp[i]) {
repeat[i] = true;
} else {
temp[i] = true;
}
}
return repeat;
}
网友评论