1function toUniqueArray(a){
2 var newArr = [];
3 for (var i = 0; i < a.length; i++) {
4 if (newArr.indexOf(a[i]) === -1) {
5 newArr.push(a[i]);
6 }
7 }
8 return newArr;
9}
10var colors = ["red","red","green","green","green"];
11var colorsUnique=toUniqueArray(colors); // ["red","green"]