JS:
var arrData = [1,3,5,7,7,8,9,3,10,8,"sdsdsds","sss","ffff","sss","sss"];
function uniqueArray(data){
data = data || [];
var a = {};
for (var i=0; i<data.length; i++) {
var v = data[i];
if (typeof(a[v]) == 'undefined'){
a[v] = 1;
}
};
data.length=0;
for (var i in a){
data[data.length] = i;
}
return data;
}
uniqueArray(arrData);
调用后:
["1", "3", "5", "7", "8", "9", "10", "sdsdsds", "sss", "ffff"]