On my search for concrete numbers to back usage of the const
keyword in Javascript, I stumbled upon a performance comparision between all three variable declaration types var, let and const. I didn't like the test setup, so I created a simplified one.
I didn't expect much difference and Firefox measured up to my expectations:
But in Chromium something weird happened:
Not only are all test results significantly lower but let
inside the loop breaks down to a fraction of the speed.
I decided to run the tests in Browserstack to make sure it is not my quirky Linux setup. The same happens there with Firefox 53
and Chrome 58
on Windows 10. I even tested the somewhat older Chrome 50
and got the same behaviour.
What is going on? Is it a bug?
EDIT: Some commented that the loop is probably just optimized away as it is doing nothing. To show, that this is not the case, I changed the test.