Currently viewing "Introduction to Arrays and Objects" (Open Console by Right click > Inspect > Console or press F12)

Arrays

What is Array:

An array is a data structure that stores multiple values in a single variable. Learn more

Why use Array:

Arrays allow storing and managing multiple values efficiently, reducing the need for separate variables. Read more

Where to use Array:

Arrays are used in data storage, iteration, and manipulation, such as storing user lists or handling game data.

How to create and access members of an Array:

let arr = [1, 2, 3]; console.log(arr[0]); // Output: 1 More on Accessing Arrays

When to use new Array();

Use new Array() for dynamic array creation or predefined size initialization. More details

Objects

What is object:

Objects are collections of key-value pairs used to store structured data. Learn more

How to write Object:

let person = { name: "Alice", age: 25 }; Object Syntax

Why and when to use Object:

Objects are used for storing structured data like user profiles, configurations, or API responses.

How to access Object:

console.log(person.name); // Output: Alice Guide to Objects

When to use new Object():

Use new Object() for dynamic object creation when keys and values are unknown at initialization.

Nested object:

let user = { profile: { name: "John", age: 30 } }; Nested Objects