for (index=1; index<=15; index++) {
if (undefined != sku[index]) {
found = jQuery.inArray(sku[index], mr_sku);
if( found == -1){ //not in array
alert( sku[index] + " NOT FOUND - delete index " + index );
} else { // in array
alert("FOUND");
}
}
}
两个数组--sku和mr_sku =试图找到1到15之间的值,其中未定义值在两个数组中。我知道sku [1]和mr_sku是相同的值 - 只是在数组中显示为bieng - inarray总是以-1返回
答案 0 :(得分:0)
使用虚拟数据进行测试,它运行正常。这是jsfiddle,这是我使用的数据:
var sku = ['a','b','c'];
var mr_sku = ['a','c','c'];
for (index=1; index<=2; index++) {
if (undefined != sku[index]) {
found = jQuery.inArray(sku[index], mr_sku);
if( found == -1){ //not in array
alert( sku[index] + " NOT FOUND - delete index " + index );
} else { // in array
alert("FOUND");
}
}
}