Ввод:
array = [1,2,3,4,4,5,6,7,8,8,9 ,10];
Ожидаемый результат:
массив = [1,2,3,4,5,6,7,8,9,10,11,12]
Код: Выделить всё
const array = [1,2,3,4,4,5,6,7,8,8,9,10];
const duplicates = array.filter((item, index) => array.indexOf(item) !== index);
console.log(duplicates); // Output: [2, 4, 5]Подробнее здесь: https://stackoverflow.com/questions/785 ... alue-using