• Home
  • Blog
  • Projects
  • Links
  • Search /
Hi! I’m ZanderStylised (pixellated) picture of Zander, I make web apps

❌Remove array duplicates with Set

https://www.samanthaming.com/tidbits/43-3-ways-to-remove-array-duplicates
1 Dec 2023
javascript
On this page
  1. Using Set

Using Set

const array = ['🐑', 1, 2, '🐑', '🐑', 3]

// Step 1
const uniqueSet = new Set(array)
// Set { '🐑', 1, 2, 3 }

// Step 2
const backToArray = [...uniqueSet]
// ['🐑', 1, 2, 3]

// or Step 1
const uniqueSet = [...new Set(array)]
// ['🐑', 1, 2, 3]
> cd ..
I'm available for work right now.
Get in touch
  • CV/Resume
  • Code Notes
  • Feeds
  • Colophon
  • Now
  • Uses
  • Zed Stack
  • Lab
  • GitHub
  • Bluesky
  • ASCII mode

© 2026 Zander Martineau • #cb09ef2 • This site is always under construction. 🚧

This site comes in four flavours.

  • Website The ordinary site. You are here.
  • Desktop Windows, a menu bar and Spotlight, like an old Mac.
  • Terminal Keyboard only. Arrow keys, Enter and Esc.
  • Plain text No stylesheets. Just the browser defaults.