Objects
A JavaScript object is just a collection of properties. A property is a "key: value" pair, where the key is always a string, and value can be any data type, like strings, numbers, Booleans or referrence data type like arrays, functions, and other objects. And properties with their values as functions are called as methods.
An object can be created with curly brackets .
Syntax
Example :
In above example, the object name is person that has three properties name, age, gender and one method displayName() .
Accessing Object’s Properties
To access the value of a property, we can use the dot (.), or square bracket ([ ]) notation.
Example :
Setting Object’s Properties
We can set the new properties or update the existing one using the dot (.) or bracket ([]) notation.
Example :
Calling Object’s Methods
Example :
Finding Object’s length
Example :