var str = new Array(); 比如有这么一组数组,里面放了20个18位的身份证号码 要判断里面的身份证号码是否有重复 如何快速判断?
代码如下:
var ary = new Array("111","22","33","111"); var s = ary.join(",")+","; for(var i=0;i { if(s.replace(ary[i]+",","").indexOf(ary[i]+",")>-1) { alert("有重复!"); } }
代码如下:
var ary = new Array("111","22","33","111"); var nary=ary.sort(); for(var i=0;i {if (nary[i]==nary[i+1]) {alert("重复内容:"+nary[i]);} }