📜  出现奇数次的js数组值 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:54.077000             🧑  作者: Mango

代码示例2
function findOdd(A) {
    let counts = A.reduce((p, n) => (p[n] = ++p[n] || 1, p), {});
    return +Object.keys(counts).find(k => counts[k] % 2) || undefined;
}