var arr1 = [1, 2, 3];
var arr2 = [1, 2, 3];
function arrayEqual(arr1, arr2) {
if(arr1 === arr2) return true;
if(arr1.length != arr2.length) return false;
for(var i = 0; i < arr1.length; ++i) {
if(arr1[i] !== arr2[i]) return false;
}
return true;
}
if(arrayEqual(arr1, arr2)) {
console.log("相等");
} else {
console.log("不相等");
}
判断两个数组是否全等
最新推荐文章于 2024-02-07 16:00:28 发布