[1, 2, 2.1, 3, 4, 4.1 ] //...etc
我想做的是在一个调用中将幻灯片的所有细节传递给幻灯片API。为此,我想在创建“2”幻灯片的调用中传递“2.1”数组。为此,我需要对阵列进行前瞻。
这是我用来测试的代码和我的
JSFiddle
var foo = new Array();
var firstProduct;
var secondProduct = "";
var order;
foo = [
[1, "one2", "one3"],
[2, "two2", "two3"],
[2.1, "two21", "two31"],
[3, "three2", "three3"]
];
for (var i = 0; i < foo.length; i++) {
firstProduct = foo[i][0];
if (foo[i][0] <= foo.length) {
secondProduct = foo[i + 1][0];
if (typeof secondProduct !== 'undefined' && Math.floor(firstProduct) == Math.floor(secondProduct)) {
alert("Match " + firstProduct + " " + secondProduct);
i++;
}
else {
alert("No match - firstProduct" + firstProduct);
}
}
else {
alert("last " + firstProduct);
}
}
VM3349:59未捕获类型错误:无法读取未定义的属性“0”
在窗口。空载(VM3349:59)