Missing Array Elements
As a sane programmer, you probably wouldn’t ever think to do this. But It’s perfectly legal to do so.
I recently did this by accident:
var a:Array = [1,2,3,,4,5,6];
Note the missing fourth element of the array. It was a typo that I left it out and it pretty much immediately turned around to bite me. You won’t get a compiler error or warning or even necessarily a runtime exception. Here’s what you’ve implicitly told the compiler to generate:
var a:Array = [1,2,3,undefined,4,5,6];
Naturally, you’ll go to use the array and expect to find only the types of values you put in it, like I put integers here. If you’re using an Object type rather than ints, you’re very likely to try to use undefined. That’s when you’ll get the crash.
Watch out for missing array elements! (this also goes for JavaScript)