Cache the length and use i += 1 (also should use !== instead of &lt;).