let vs var performance (v40)

Revision 40 of this benchmark created by noname on


Preparation HTML

<script>

  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

Ready to run.

Testing in
TestOps/sec
var
!function() {
'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);
}
}();
ready
let
!function() {
'use strict';

var resultarray = [];

for (let i = 0; i < 1000; i++) {
  let firstnumber = firstarray[i];
  let secondnumber = secondarray[i] + 5;
  let total = firstnumber + secondnumber;
  resultarray.push(total);
}
}();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.