如何检查数组列表中是否包含值? 例如:
var number = [1, 9, 9, 4];
if(number == [1, 9, 9, 4]){ //true}
else if(number == [2, 1, 5, 4){ //false;}
else if(number == [9, 1, 4, 9){ //false;}
是否有任何方法可以检查数组列表是否包含值,例如“ 1994”? 非常感谢!!!!
答案 0 :(得分:0)
您可以这样:
function arrays_equal(a,b) { return !!a && !!b && !(a<b || b<a); }
var number1 = [1, 9, 9, 4];
var number2 = [1, 9, 9, 4];
var number3 = [1, 3, 2, 4];
var number4 = [2, 3, 2, 4];
console.log(arrays_equal(number1, number2));
console.log(arrays_equal(number1, number3));
console.log(arrays_equal(number2, number3));