A while back I read a couple of blogposts about the slowness of using uint and int to iterate through for-loops. I needed to do some testing for a little project today and found this is false.

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:

The proof out there was what I linked to in the post. They were loops that were doing mathematical operations with the “i” variable. Using Number was faster in that scenario. This is less common then simply iterating over a loop.

I found that uint is ever-so-slightly faster than int and much faster than Number if you are simply iterating over a loop.