three different ways to create objects in JavaScript:

Created with Sketch.

three different ways to create objects in JavaScript:

  1. Object Literal Notation:
var obj = {
  key1: value1,
  key2: value2,
  ...
};
  1. Object Constructor Notation:
var obj = new Object();
obj.key1 = value1;
obj.key2 = value2;
...
  1. Using Object.create() Method:
var obj = Object.create(Object.prototype);
obj.key1 = value1;
obj.key2 = value2;
...

Leave a Reply

Your email address will not be published. Required fields are marked *