Method 1:
var ary = new Array("111" ,"22","33","111");
var s = ary.join(",") ",";
for(var i=0;i< ary.length;i ) {
if(s.replace(ary[i] ",","").indexOf(ary[i] ",")>-1) {
alert("There are duplicate elements in the array: " ary[i]);
break;Foreign Language House
}
}
Method 2:
var ary = new Array(" 111","22","33","111");
var nary=ary.sort();
for(var i=0;i
if (nary[i]==nary[i 1]){
alert("Array duplicate content: " nary[i]);
}
}
Method three: Inland transportation
function isRepeat(arr){
var hash = {};
for(var i in arr) {
if (hash[arr[i]])
return true;
hash[arr[i]] = true;
}
return false;
}