return object function vs return function reference

JavaScript performance comparison

Test case created

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
object function
var func = function () {
  var yo = function (num) {
    for (var i = num; i < 2000; i++) num += i;
  };
  return {
    yo: yo
  }
}

for (var i = 0; i < 1000; i++) func().yo(i);
pending…
object function redefined
var func = function () {
  return {
    yo: function (num) {
      for (var i = num; i < 2000; i++) num += i;
    }
  }
}

for (var i = 0; i < 1000; i++) func().yo(i);
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