Function constructor vs Declared Function (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script>
  var fn1 = new Function("for(var i=0; i<100; i++);");
  var fn2 = function() {for (var i = 0; i < 100; i++);};
  var fn3 = (new Function('j', 'for (var i = j; i < 104; i++);'))(4);
  var fn4 = (function(j){return function(){for (var i = j; i < 104; i++);};}
    )(4);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
new Function
fn1();
ready
FunctionExpression
fn2();
ready
complex new Function
fn3();
ready
FunctionExpression with custom scope
fn4();
ready

Revisions

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

  • Revision 1: published by Christian C. Salvadó on
  • Revision 3: published on