Skip to main content
code•choose best-code•javascript
0s
+15 XP

Array Deduplication: Set vs Filter

Which code snippet demonstrates the most idiomatic, modern, and high-performance approach to removing duplicate values from an array in JavaScript?

javascript
// Version A
const unique = [...new Set(array)];
Version B
// Version B const unique = array.filter((item, index) => array.indexOf(item) === index);
Exit to Challenges