let arr = [1, 2, 3, 4, 5, 5]; const seen = new Set(); const duplicates = arr.filter(n => seen.size === seen.add(n).size); console.log(duplicates); // [ 5 ] console.log(duplicates.length); // 1