numOne = [1, 2]
numTwo = [1, 3, 1]
let duplicatedValues = […new Set(numOne)].filter(item => numTwo.includes(item));
let firstValues = new Set(numOne);
duplicatedValues = numTwo.filter(item => firstValues.has(item));
// [1, 1]
to solve this we need either to create second Set or to use includes instead of has
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.