OneCompiler

[Javascript] What is the simplest way to return only unique elements present in an array in Javascript

I'm newbie in learning Javascript, is there any simplest and easiest way to return only unique values present in an array with out using loops?

1 Answer

4 years ago by

You can use Set which is introduced in ES6. [...new Set(arrayName)] gives you unique values of any type present in the given array.

4 years ago by Jahaan