DEV Community

Cover image for Get all unique values from an array
Wagner Souza
Wagner Souza

Posted on

Get all unique values from an array

๐Ÿ’ก #tip - How to remove duplicate items in the array?

It's simple!๐Ÿ‘‡

It's simple

const array = [1, 2, 2, 3, 4, 4]; const uniqueValues = [...new Set(array)]; // [1, 2, 3, 4] 
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“š References

  • ... (spread operator) - MDN
  • new Set - MDN

Top comments (0)