Skip to main content

Command Palette

Search for a command to run...

Remove duplicate values from an array - Daily JavaScript Tips #4

Published
•1 min read
Remove duplicate values from an array - Daily JavaScript Tips #4
D

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.

A clever and easy way to obtain distinct values from an array is by converting the array to a Set

const removeDuplicates = (arr) => [...new Set(arr)];
removeDuplicates ([1, 2, 3, 3, 4, 4, 5, 5, 6, 7, 11, 11, 14, 14, 14]) ;

Thank you for reading, have a nice day!

More from this blog

D

Dhairya Shah

119 posts