inner function vs global function

JavaScript performance comparison

Test case created by Göran Andersson

Info

Compares performance between inner functions and global functions.

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
inner
var i = 0;
function i1() {
  function i2() { i++; };
  i2();
}
i1();
 
pending…
global
var i = 0;
function g1() {
  g2();
}
function g2() { i++; }
g1();
 
pending…
literal
var i = 0;
function l1() {
  var l2 = function() { i++; };
  l2();
}
l1();
 
pending…

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

Compare results of other browsers

0 comments

Add a comment