Eval vs new Function vs function() (v10)

Revision 10 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Eval
eval('(function(test) { return test.a; })')({
  a: true
})
ready
new Function
new Function('test', 'return test.a;')({
  a: true
})
ready
function
(function(test) {
  return test.a
})({
  a: true
})
ready
eval (no args)
eval('(function() { return true; })')()
ready
new Function (no args)
new Function('return true;')()
ready
function(no args)
(function() {
  return true;
})()
ready
declared function
function f(test) {
  return test.a
}

f({
  a: true
});
ready
declared function (no args)
function f(test) {
  return true;
}

f();
ready

Revisions

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