new Function vs eval

Benchmark created by lamaster on


Preparation HTML

<script>
  var jsonString = '[{"some":"kind","of":1,"json":{"string":["with","a","lot","of","things"]}}]'
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
new Function
var result = (new Function("return " + jsonString))()
ready
eval
var result = eval(jsonString);
ready
JSON.parse
var result = JSON.parse(jsonString);
ready

Revisions

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

  • Revision 1: published by lamaster on