let vs var

JavaScript performance comparison

Revision 4 of this test case created by and last updated

Preparation code

<script language="javascript" type="application/javascript;version=1.7">
window.onload = function() {
    var target = document.documentElement,
        observer = new MutationObserver(function (mutations) {
            mutations.forEach(function (mutation) {
                [].forEach.call(mutation.addedNodes, function(el) {
                    if (el.nodeName.toLowerCase() === "script") {
                        el.type = "application/javascript;version=1.7";
                    }
                });
            });
        }),
        config = {
            childList: true,
            subtree: true
        };

    observer.observe(target, config);
};
</script>
    

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
let
;(function() {
  let letTest = "foo bar baz";
}());
pending…
var
;(function() {
  var varTest = "foo bar baz";
}());
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.

0 Comments