js判断数组里面的值是否相等。

时间:2023-03-08 16:15:49
 var zhi=[];
    var zhiT=[];
    //var arr=["a","b","a","a"];
    var arr=["a","a","a","a"];
   // var arr=["b","b","b","b"];
    for(var i=0;i<arr.length;i++){
        zhi.push("a");
        zhiT.push("b");
    }
if(zhi.toString()==arr.toString() && zhi[0]=="a"){
    alert("相等"+zhi[0]);
}else if(zhiT.toString()==arr.toString() && zhiT[0]=="b"){
    alert("相等"+zhiT[0])
}else{
    alert("不相等"+",其他");
}
</script>