Monday, January 10, 2011

JQuery-Remove Duplicates from an Array

function uniqueArray(myarray)// to remove the duplicates from an Array
{
//var vals = this;
var uniques = [];
for(var i=myarray.length;i--;){
var val = myarray[i];
if($.inArray( val, uniques )===-1){
uniques.unshift(val);
}
}

return uniques;
}

No comments:

Post a Comment