New Toronto Group
 - New Toronto Group

JavaScript Object Creation Times

| Posted on November 06th, 2012 by Oliver Merk

By Oliver Merk - principal consultant

There are three common ways to create JavaScript objects.

The one most of us learned first was the constructor call:

var myObj = new Object();

Then we got clever and impressed our friends by using object literal syntax:

var myObj = {};

Now, with the latest version of ECMAScript, we can use:

var myObj = Object.create(proto);

...where proto is the object to be used as the prototype of the new object. You will typically set this to null or {}.

Which of these three do you think is the fastest? Which is the slowest?

The results may surprise you as much as they did me.

Follow this link and have your JavaScript Console open when you click the Run test button:

Posted in javascript, Oliver Merk  | Comments (0)

Comments (0)

Add a Comment

To use reCAPTCHA you must get an API key from

Allowed tags: <b><i><br>Add a new comment: