Basically, the syntax will look like this:
Let’s take a look at some simple examples of what are called object literals.
Object Literal Syntax
An object literal represents a value that you literally add to your script. It has a fixed value.
Here is the syntax of an object literal:
We assign the object literal to a variable
obj. The following are what we call name/value pairs or key/value pairs where
key is a property of the object and
value is the value of that property.
We add properties to the Cat constructor through dot notation and adding a value, much like before:
You can access properties in an object with dot or bracket notation. For instance:
If we take a look at our Cat constructor, we can access its age by using either dot or bracket notation:
This will return the value 2 for atticus and felix.
Looks similar but it isn’t. It is a simpler way to exhange data. Previously XML was used to store and exhange serialized data but this is far simpler and is the most widely adopted way to do this.
this, and more.