new Object versus JSON

Benchmark created by Nicolas Chambrier (@naholyr) on


Description

Which is the best for initializing a hash ?

Test runner

Ready to run.

Testing in
TestOps/sec
new Object + Assignations
var options = new Object();
options.first_name = "Hello";
options.nick_name = "world";
options.age = 42;
ready
new Object
var options = new Object({
  "first_name": "Hello",
  "nick_name": "world",
  "age": 42
});
ready
Object.create
var options = Object.create({
  "first_name": "Hello",
  "nick_name": "world",
  "age": 42
});
ready
JSON
var options = {
  "first_name": "Hello",
  "nick_name": "world",
  "age": 42
};
ready

Revisions

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

  • Revision 1: published by Nicolas Chambrier (@naholyr) on