A JavaScript object is a collection of key–value pairs, used to store structured data.
1. Creating Objects
Object Literal (Most Common)
Using new Object()
2. Accessing Object Properties
Dot Notation
Bracket Notation
Use bracket notation when:
- Property name has spaces
- Property name is dynamic
3. Adding, Updating, and Deleting Properties
4. Objects with Methods
Objects can contain functions (methods).
this refers to the current object.
5. Nested Objects
6. Looping Through Objects
for...in Loop
Object.keys()
Object.values()
Object.entries()
7. Copying Objects
Shallow Copy
or using spread operator:
Deep Copy
⚠ Does not copy methods or undefined values.
8. Object Destructuring (ES6)
9. Object Properties Check
10. Object Freezing & Sealing
Object.freeze()
Object.seal()
11. Reference Behavior of Objects
Objects are stored by reference.
