Set Set Object
Last updated: 2026-09-09
Set Set Object
Set is a collection of unique values — the standard dedup method.
| Category | Collections |
|---|---|
| ES version | ES1 |
📝 Syntax
const set = new Set([1, 2, 2]);
▶ Example
Edit the code, press Run, and see the result in the output panel:
Output:
[1, 2, 3]
💡 Tip Spread + Set is the shortest dedup.
ℹ️ info Set.add returns itself — chainable.
🏷️ Related Items
💡 Related Cases
More case studies coming soon — check back later.
📚 Related Tutorials
❓ FAQ
QHow does Set dedup?
AUses SameValueZero algorithm.
QSet vs Array?
ASet deduplicates with O(1) lookup.
QSet vs WeakSet?
AWeakSet holds weak object refs.