var origin = [1, 2, 'a', 3, 1, 'b', 'a']; var result = new Set(); var repeat = new Set(); origin.forEach(item => { result.has(item) ? repeat.add(item) : result.add(item); }) console.log(result); // {1, 2, "a", 3, "b"} console.log(repeat); // {1, "a"}