4 more Javascript hacks to make your javascript faster
Nicholas Ortenzio

Are you retarded? Those loops are both equivalent in time complexity, but the second one involves branching, so it’d probably be even slower. Oh, and the third one is even worse, because, surprise surprise, the loop body is actually there to make code CLEARER by separating the increments from the body, a useful abstraction which you just undid in the most cumbersome and inelegant way possible, while also (negligibly) decreasing performance.

n<<2 is multiply by 2² =4, not by 3! I have literally never seen anyone make a mistake this stupid with bit-shifting. More importantly, though, most JS engines worth their salt already make this optimization. Oh, and the rounding thing actually makes scripts slower (time it yourself if you don’t believe me.)