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
3. Object Constructor Function: Use a function with
2. Object Instance: Use the
new Object() syntax.3. Object Constructor Function: Use a function with
this to assign properties.Code Example
PREVIEW READY
πΈ JavaScript Array of Objects
Arrays can hold multiple objects. Each object can contain various properties.
Code Example
PREVIEW READY
πΈ 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
πΈ 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
π§ Test Your Knowledge
10 QuestionsProgress: 0 / 10
Keep Going!JS - Map