//判断两个数组是否相等:
var aArray1 = ["1","I","2","N","3","S"],aArray2 = ["1","I","2","N","3","S"];
if(aArray1.sort().toString() == aArray2.sort().toString()){
alert("相等");
}
else{
alert("不相等");
}
判断一个数组中是否有重复的元素:
var aTitleList = ["1","I","2","N","3","S"],bRepeat = false;
$.each(aTitleList.sort(), function (iIndex, sItem) {
if (iIndex + 1 < aTitleList.length) {
if (aTitleList[iIndex] == aTitleList[iIndex + 1]) {
bRepeat = true;
alert("有重复元素" + sItem);
//return false;
}
}
});
if(bRepeat){
alert("有重复元素!");
}
else{
alert("没有重复元素!");
}