I have a javascript function to populate dropdowns for individual table rows like:
$scope.possibleOptions = getUniqueValues($scope.yypeOptions, \'yypeOption\
The getUniqueValues there is performing two things for you; removing duplicated elements and also cloning the array. However, the map already is a clone of the array, so you just need to remove duplicates; you could use something like this:
function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
}
function getUniqueValues(array, prop) {
function mapper(item) {
return item[prop];
}
return array.map(mapper).filter(onlyUnique);
}
I'd suggest you to take a look at stuff like webpack and babel in order to use the latest JS and also work on IE, by using transpiler and polyfills to generate compatible code ;)
PS. I don't have IE right now to test if filter works, but I'm pretty sure it does; otherwise you could remove duplicates by hand with a plain old for.