𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗢𝗯𝗷𝗲𝗰𝘁𝘀: 𝗕𝗮𝘀𝗶𝗰𝘀 𝘁𝗼 𝗖𝗥𝗨𝗗

JavaScript objects store data and logic together. You use them to group related information into one place.

Think of an object as a real-world entity.

An entity is a thing you can identify. A student is an entity. An object has two parts:

In code, state is called a property. Behavior is called a method.

How to create objects

You have two main ways to build an object.

  1. Object Literal This uses curly braces. It is the most common method. It is short and clean. let student = { name: "Saravanan", age: 25 };

  2. Object Constructor This uses the new keyword. let student = new Object(); student.name = "Saravanan";

Most developers use the literal method because it is easier to read.

The CRUD Operations

You manage data in objects using four basic actions:

Advanced Object Features

Methods A function inside an object is a method. You can use shorthand to write them. let person = { greet() { console.log("Hello"); } };

Nested Objects An object can hold another object. This is a nested object. let person = { address: { city: "Chennai", state: "Tamil Nadu" } }; You access it like this: person.address.city.

Objects can store many types:

Source: https://dev.to/dev_saravanan_journey/javascript-objects-from-basics-to-crud-operations-46bg