Classmate mentioned to me that he read the decrementer (--
) was supposed to perform operations faster than the incrementer (++
). We ran a test with JavaScript and came up with mixed results.
On my MacBook Pro i5 (mid-2014), ++
was almost 3 times faster than --
when using the console.time method to log the difference in Chrome, and in Firefox ++
just barely edged out --
.
On his Windows laptop (unsure the model), it was nearly the exact opposite with --
coming in much faster across the browsers.
So what's happening? Is this hardware or software? What's the difference and why would either one or the other operate at any greater or lesser speed?
The question here is why is there a difference on different machines? Comparison to 0 would seem like an obvious answer why we're seeing the decrement slower on my MacBook, but it doesn't explain why it's actually faster on the window's machine.
We expected decrement to be slower in both cases and were just testing the difference, then we came up with this strange result. Hence this question.