function declaration vs function expression

JavaScript performance comparison

Revision 19 of this test case created by and last updated

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
var myfunc2 = function() {
 return true;
};

for(i=0 ; i<10000 ; i++) {
  myfunc2();
}
pending…
function declaration
function myfunc1() {
 return true;
}

for(i=0 ; i<10000 ; i++) {
  myfunc1();
}
pending…
named function expression
var myfunc3 = function test() {
 return true;
};

for(i=0 ; i<10000 ; i++) {
  myfunc3();
}
pending…
nested function expression
var myfunc4 = function() {
 function myfunc5(){
   return true;
 }
 for(i=0 ; i<10000 ; i++) {
   myfunc5();
 }
}
//myfunc4();
pending…
nested function declaration
var myfunc6 = function() {
 var myfunc7 = function(){
   return true;
 }
 for(i=0 ; i<10000 ; i++) {
   myfunc7();
 }
}
//myfunc6();
pending…
outer function expression
function myfunc8() {
 function myfunc9(){
   return true;
 }
 for(i=0 ; i<10000 ; i++) {
   myfunc9();
 }
}
//myfunc8();
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