function declaration vs function expression

JavaScript performance comparison

Revision 26 of this test case created by dh

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var glob = 0;
  function decl(glob) {
    return glob + 1;
  }
  var expr = function(glob) {
    return glob + 1;
  }
  
  this.__proto__.evilProto = function(glob) {
    return glob + 1;
  }

};
</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
function expression
glob = expr(glob);
pending…
IIFE
glob = (function(glob) {
  return glob + 1;
})();
pending…
evil proto
glob = this.evilProto(glob);
pending…
function declaration
glob = decl(glob);
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