Your loop is constructed incorrectly. When you want to set a variable in a loop to access an element of an array or object, this is the correct syntax:
var test = [];
for(var i = 0; i < test.length; test++)
(function(index){
// do cool stuff with test[index]
})(i);
This creates a closure over the variable i. If you aren't familiar with the syntax, here's what happens:
1) We define a closure (the opening ()'s after the for statement)
2) We define an anonymous function to take the index parameter
3) We pass the index into the closure (i.e. we execute the function)with the final set of ()'s.
These three steps happen for every iteration of the loop. If you don't use the closure to capture the index value, then when the array access is actually made, the index in this example would be +1 too many, and cause errors at runtime.
Cheers
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…