我希望同时遍历两个数组,因为数组A中任何给定索引i的值都对应于数组B中的值。
目前我正在使用这段代码,但是当我调用alert(queryPredicates[i])
或alert(queryObjects[i])
时会得到undefined
。
我知道我的数组已经被填充了,因为在调用之前我打印了出来。
//queryPredicates[] and queryObjects[] are defined above as global vars - not in a particular function, and I have checked that they contain the correct information.
function getObjectCount(){
var variables = queryPredicates.length; //the number of variables is found by the length of the arrays - they should both be of the same length
var queryString="count="+variables;
for(var i=1; i<=variables;i++){
alert(queryPredicates[i]);
alert(queryObjects[i]);
}
queryPredicates
是否具有数字索引? - bschaefferalert(queryPredicates);
,alert(queryObjects);
),看看那会给你什么提示。 - Steve Harrison