1const yourArray = [1, 1, 2, 3, 4, 5, 5]
2
3const yourArrayWithoutDuplicates = [...new Set(yourArray)]
4
5let duplicates = [...yourArray]
6yourArrayWithoutDuplicates.forEach((item) => {
7 const i = duplicates.indexOf(item)
8 duplicates = duplicates
9 .slice(0, i)
10 .concat(duplicates.slice(i + 1, duplicates.length))
11})
12
13console.log(duplicates) //[ 1, 5 ]
14