Sunday 15 June 2014

javascript - do the parantheses matter? -


Looking at this test

Why is it fast

  Var x; Var i = 1E4; Var j = 1e4; For (; i--> -1;) {x = - ~ x; } For (; j--> -1;) {x = ~ - x; }   

From this?

  var x; Var i = 1E4; Var j = 1E4; For (; j -> gt; -1;) {x = -1 * ~ x; } For (- j -> gt; -1;) {x = ~ (-1 * x); }   

Is the second version better customizable, or what is the reason?

In the second code sample, you use j as an itater in both loops.

No comments:

Post a Comment