Is element in an array undefined
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var numbers:Array = new Array(4, 10);
numbers[4] = 1;
trace(numbers);
for(var i:int = 0; i < numbers.length; i++) {
if(numbers[i] == undefined) {
numbers.splice(i, 1);
i--;
}
}
trace(numbers);
}
}
}
// 4,10,,,1
// 4,10,1
Related examples in the same category