const vs var

JavaScript performance comparison

Test case created by Josh

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
const
const foo = 12;
const bar = "foobar";

const hello = [];

const world = function () {
  hello.push(foo);
  hello.push(bar);
  return hello;
};

world();
pending…
var
var foo = 12;
var bar = "foobar";

var hello = [];

var world = function () {
  hello.push(foo);
  hello.push(bar);
  return hello;
};

world();
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