const num = [1, 2, 3, 4, 2, 3, 4, 6, 8];
let map = new Map();
let output = num.map((item) => {
if (map.has(item)) {
return item;
}
map.set(item);
});
//output - [undefined, undefined, undefined, undefined, 2, 3, 4, undefined, undefined]
console.log(output.find((i) => i));