JavaScript Objects

JavaScript Objects
In JavaScript, an object is a collection of related data stored in key-value pairs. Keys are call properties, and values can be strings, numbers, arrays, functions, or even other objects.
Objects help organize data in a structured way.
Creating an Object
Accessing Object Properties
You can access properties in two ways:
1. Dot Notation
2. Bracket Notation
Adding & Updating Properties
Deleting a Property
Objects with Methods
A method is a function inside an object.
Output:
Nested Objects
Objects can contain other objects.
Looping Through an Object
Use for...in loop:
Object Constructor
Summary
| Feature | Description |
|---|---|
| Store multiple values | Using key-value pairs |
| Access values | Dot . or bracket [] |
| Can have functions | Called methods |
| Can be nested | Object inside object |
JavaScript objects are the foundation of modern JavaScript programming and are heavily use in frameworks like React, Node.js, and APIs.
