Table of Contents
For example, suppose you want to store the information of 30 different people. Using 30 separate variables for each person and their information can make the code complicated and heavy. However, by using objects, this information can be stored in an organized and grouped manner. In simpler terms, objects are like boxes that hold different types of data (eg name, age, address) inside them.
In general, objects are used to store related data and to structure code more logically. Objects provide the possibility to store different data with any type of properties in an Object.
Using other objects in an object
As mentioned, an object can contain other objects. This concept is called Nested Objects or “internal objects”. That is, an object can hold another object inside itself.
Using functions in objects
Changing the value of an attribute on objects
To change the value of a property, the equal operator (=) is used.
Add new properties to objects
Delete an object attribute
To delete an attribute or feature from an Object, the delete operator is used.
Checking the presence of a feature in an object
To check whether an attribute exists in an object or not, the “in” operator is used. The “in” operator returns true if there is a property with the desired name (propertyName) inside the desired object (objectName), and false otherwise.