📅  最后修改于: 2022-03-11 15:04:09.088000             🧑  作者: Mango
function getNotUnique(array) {
var map = new Map();
array.forEach(a => map.set(a, (map.get(a) || 0) + 1));
return array.filter(a => map.get(a) > 1);
}
console.log(getNotUnique([1, 2, 2, 4, 4])); //[2, 2, 4, 4]
console.log(getNotUnique([1, 2, 3] )); //[]