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)