Remove duplicates from an array
A function that removes duplicates in an array.
by Akram kamal
HTML
<a href="http://stackoverflow.com/questions/12551635/jquery-remove-duplicates-from-an-array-of-strings/12551709#12551709">Stackoverflow: remove duplicates from an array of strings</a>
JavaScript
function unique(list) {
var result = [];
$.each(list, function(i, e) {
if ($.inArray(e, result) == -1) result.push(e);
});
return result;
}
var thelist = ["ball_1", "ball_13", "ball_23", "ball_1"];
alert(unique(thelist));
console.log(unique(thelist));