Function Definition

JavaScript performance comparison

Test case created by Doncho Minkov

Preparation code

<script>
  function funcDeclaration() {}
  var funcExpression = function() {}
     
  var funcConstructor = new Function("");
  var count = 100;
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Function Declaration
for (var i = 0; i < count; i++) {
  funcDeclaration();
}
pending…
Function Expression
for (var i = 0; i < count; i++) {
  funcExpression();
}
pending…
Function Constructor
for (var i = 0; i < count; i++) {
  funcConstructor();
}
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. Here’s a list of current revisions for this page:

0 comments

Add a comment