let vs var ks

Benchmark created by Kerri Shotts on


Test runner

Ready to run.

Testing in
TestOps/sec
let
function foo(x) {
  let c = 0;
  for (let i = 0; i < x * 30000; i++) {
    c = c + x;
  }
  return c;
}
foo(50);
ready
var
function foo(x) {
  var c = 0;
  for (var i = 0; i < x * 30000; i++) {
    c = c + x;
  }
  return c;
}
foo(50);
ready
var in fn
function foo(x) {
  var c = 0;
  for (var i = 0; i < x * 30000; i++) {
    (function (i) {
      return c = c + x;
    }).call(undefined, i);
  }
  return c;
}
foo(50);
ready

Revisions

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

  • Revision 1: published by Kerri Shotts on