Difference Between New Object and Object Literal Notation in JavaScript



Both new Object() notation and Object literal({}) notations do the same thing. They initialize an object. However, the second notation can be a little different if you start adding properties to it.

Example

let a = {
   name: 'Ayush'
}

This initialization is equivalent to −

let a = new Object();
a.name = 'Ayush'

or

let a = {}
a.name = 'Ayush'
Updated on: 2019-11-27T09:41:34+05:30

596 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements