Is there a technique or an easy way in returning all the duplicate values, and also if possible, their indices. And also the unique ones, and their indices. How can I achieve this? (may or may not be using objects)
Ex.
var setOfValues = [1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 10, 10, 9, 10, 8 , 4, 11];
unique = {
values: [1, 5, 9, 8, 4, 11],
indices: [0, 9, 12, 14, 15, 16]
};
duplicates = {
values: [2, 2, 2, 3, 3, 4, 4, 4, 10, 10, 10],
indices: [1, 2, 3, 4, 5, 6, 7, 8, 10, 11]
};