Cache the length, use j += 1 and use !== instead of &lt;