JavaScript Objects

JavaScript Objects

In JavaScript, an object is a collection of related data stored in key-value pairs. Keys are called 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:

Car is starting...

✔ 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 used in frameworks like React, Node.js, and APIs.

CodeCapsule

Sanjit Sinha — Web Developer | PHP • Laravel • CodeIgniter • MySQL • Bootstrap Founder, CodeCapsule — Student projects & practical coding guides. Email: info@codecapsule.in • Website: CodeCapsule.in

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *