201506022038_《JavaScript权威指南-判断两个数组相等》(p38-48)
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [1, 2, 3, 4, 5];
function equalArrays(a, b) {
if (a.length != b.length) {
alert("错啦,数组长度不相等!"
);
return
} else {
for (var i = 0; i < a.length; i++) {
if (a[i] != b[i]) {
alert("值不相等!");
return
}
}
alert("两数组相等!");
return
}
};
equalArrays(arr1, arr2);
前端-语言