I have an array such as:
var aos = ["a","a","b","c","d"];
and I want to know if I can find duplicates of each index and store them into something such as an arraylist? For instance we start at:
aos[0]
That then checks to see if
a
is found, and it will keep running through the array taking all the elements with that value in index 0 storing them into a list (such as an arraylist or collection) and then removing them from the list. Is this possible?
var uniq =_.uniq(aos)Or a long winded way (ES5) :
And if you want to support ES3 then :
Store duplicates in a new array:
Live Example
_.uniq,Array.prototype.reduce,Array.prototype.some,_.any,_.select,_.after