Nearby lessons

35 of 40

πŸ“¦ JavaScript Objects & Const Usage

πŸ“Œ What are JavaScript Objects?

JavaScript Object is a non-primitive data type used to store collections of key-value pairs. It can hold properties (data) and methods (functions).

JavaScript is object-based β€” everything is treated as an object.

πŸ”Έ Object Creation Methods

1. Object Literal: Directly define key-value pairs using curly braces.
2. Object Instance: Use the new Object() syntax.
3. Object Constructor Function: Use a function with this to assign properties.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

πŸ”Έ JavaScript Array of Objects

Arrays can hold multiple objects. Each object can contain various properties.
Code Example
PREVIEW READY
Loading Editor...
Live Preview

πŸ”Έ const with Arrays

const allows array modification (like push()), but not reassignment.

You can change the contents, but not reassign the variable itself.

Code Example
PREVIEW READY
Loading Editor...
Live Preview

πŸ”Έ const with Objects

Like arrays, objects declared with const can have their properties updated.

But reassigning the object is not allowed.

Code Example
PREVIEW READY
Loading Editor...
Live Preview

🧠 Test Your Knowledge

10 Questions

Progress: 0 / 10
Keep Going!JS - Map