When using the “i” variable in for(var i = 0; i < length; i++) as an input into mathematical operation, especially when doing fractions, Number is faster for obvious reasons. This was established in the posts of the previously mentioned blogs. But when simply iterating over an array which is a very common use-case for for-loops uint is faster. Here is my test setup:
var value:Object; var arr:Array = new Array(1000000); var length:uint = arr.length; var startTime:Number = getTimer(); for (var i:uint = 0; i < length; i++) value = arr[i]; var endTime:Number = getTimer(); trace("Total Time:", endTime - startTime);
I was getting around 210 for uints and around 230 for Number. Not a big difference, but I feel dumb for always using Number for this sort of thing without even thinking about how it works.