let vs var performance

JavaScript performance comparison

Revision 6 of this test case created

Preparation code

<script>
  "use strict"
  var firstarray = [];
  for (var i = 0; i < 1000; i++) {
    firstarray[i] = Math.floor(Math.random() * 11);
  }
  var secondarray = [];
  for (var i = 0; i < 1000; i++) {
    secondarray[i] = Math.floor(Math.random() * 11);
  }
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
var
"use strict"
var resultarray = [];
for (var i = 0; i < 1000; i++) {
  var firstnumber = firstarray[i];
  var secondnumber = secondarray[i] + 5;
  var total = firstnumber + secondnumber
  resultarray.push(total);
}
pending…
let
"use strict"
var resultarray = [];
for (var i = 0; i < 1000; i++) {
  let firstnumber = firstarray[i];
  let secondnumber = secondarray[i] + 5;
  let total = firstnumber + secondnumber
  resultarray.push(total);
}
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment