方法一: 複製程式碼 程式碼如下: var ary = new Array("111" ,"22","33","111"); var s = ary.join(",") ","; for(var i=0;iif(s.replace(ary[i] ",","").indexOf(ary[i] ",")>-1) { alert("陣列中有重複元素:" ary[i]); break;外語屋} } } 方法二: 複製程式碼 程式碼如下: var ary = new Array("111 ","22","33","111"); var nary=ary.sort(); for(var i=0;iif (nary[i]==nary[i 1]){ alert("陣列重複內容:" nary[i]); } } 方法三: 內陸運輸複製程式碼 複製程式碼複製程式碼複製程式碼 function isRepeat(arr){ var hash = {}; for(var i in arr) { for(var i in arr) { if(>if(>if( hash[arr[i]]) return true; hash[arr[i]] = true; } return false }