I need to find the number of unique elements in an array.
var myArray = [ 10, 10, 20, 20, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 60 ];
I want count = 6
(number of unique elements in array)
And, is there a way to do this without iterating through the array? (I assume that would be the fastest way?).
ANSWER: I used the .filter method as shown below. My actual array element is much more complex. I ended up iterating through my array and created a new array. Each element in the new array was a .substr of the old element. Then, the .filter method below worked great. THANKS to everyone!!