• RSS Unknown Feed

    • An error has occurred; the feed is probably down. Try again later.
  • Meta

How to Create an Object in JavaScript

An object can easily be created in JavaScript by creating a new instance of the native JavaScript Object class. Following this, properties can be assigned to it, as follows:

var objCar = new Object();
objCar.wheels = 4;

document.write(objCar.wheels);

One Response

  1. I found this method to be easier

    var o = {};
    o.prop = 'val';

    and for arrays var a = [];

Leave a comment