In JavaScript, there are a bunch of ways to make new objects, but we almost always use the object literal syntax, {}.

When we write curly brackets {}, we create an empty object with no properties, which is the same as calling the Object() constructor with the new keyword: new Object() // same as {}.

We often want to specify certain object properties (also called object keys) at the same time that we create a new object.

After all, objects are simply collections of key-value pairs.

To immediately initialize the new object with properties and their values, you use the object literal syntax with a comma-separated list of key-value pairs. Each object key needs to have a value assigned.

#javascript #web-development #programming

What Is the Object Literal Syntax in JavaScript?
12.75 GEEK