OBJECT IN JS: A dynamic data structure that stores related data as key-value pairs, where each key uniquely identifies its value.
- The values of properties can be primitives, objects, or functions.
- Objects are mutable and dynamic properties can be added, modified, or deleted at any time.
- Objects allow data grouping and encapsulation, making it easier to manage related information and behaviour together.
PRIMARY WAYS TO CREATE AN OBJECT:
- Creation Using Object Literal.
- Creation Using new Object() Constructor.
CREATION USING OBJECT LITERAL: object literal syntax allows you to define and initialize an object with curly braces {}, setting properties as key-value pairs.
EXAMPLE:
const mobile1 = {
name: "iphone",
price: 50000,
storage: "512TB"
};
console.log(mobile1.price);
CREATION USING OBJECT() CONSTRUCTOR: A static method creates a new object, using an existing object as the prototype of the newly created object.
EXAMPLE:
function Mobile(){}
let mobile = new Mobile();
mobile.name = "Sourav";
mobile.age = 23;
mobile.job = "Developer";
console.log(mobile);
OPERATIONS ON OBJECT:
- Accessing Object Properties.
- Modifying Object Properties.
- Adding Properties to an Object.
- Removing Properties from an Object.
- Checking if a Property Exists.
- Iterating Through Object Properties.
- Merging Objects.
- Object Length.

Top comments (0)