TGViewer
Web Development - HTML, CSS & JavaScript Web Development - HTML, CSS & JavaScript @javascript_courses ยท 55.7K subscribers
Post #3464 1.56K
๐Ÿš€ JavaScript Arrays & Objects โ€” Complete Beginner to Advanced Guide ๐Ÿ‘จโ€๐Ÿ’ป

Arrays and Objects are the most commonly used data structures in JavaScript.

Almost every JavaScript application uses them extensively.

Examples: User data, Product lists, API responses, Dashboard data, Shopping carts

๐Ÿ“ฆ PART 1: JavaScript Arrays

๐Ÿง  1. What is an Array?

An array is used to store multiple values in a single variable.

Example:

const fruits = ["Apple", "Mango", "Banana"];


Access Elements:

console.log(fruits[0]);

Output: Apple

Important: Array indexing starts from 0.

โšก 2. Creating Arrays

Method 1: const numbers = [10, 20, 30];

Method 2: const numbers = new Array(10, 20, 30);

๐Ÿ”ฅ 3. Array Methods

push() Adds element at the end.

const arr = [1, 2];
arr.push(3);
console.log(arr);


Output: [1, 2, 3]

pop() Removes last element. arr.pop();

unshift() Adds element at beginning. arr.unshift(0);

shift() Removes first element. arr.shift();

๐Ÿ”„ 4. Loop Through Arrays

for Loop

const nums = [1,2,3];
for(let i=0; i<nums.length; i++){
console.log(nums[i]);
}


for...of

for(let num of nums){
console.log(num);
}


๐ŸŽฏ 5. map()

Creates a new array by transforming elements.

Example:

const nums = [1,2,3];
const doubled = nums.map(num => num * 2);

console.log(doubled);


Output: [2, 4, 6]

๐Ÿ”ฅ 6. filter()

Returns elements matching condition.

Example:

const nums = [1,2,3,4,5];
const even = nums.filter(num => num % 2 === 0);
console.log(even);


Output: [2, 4]

๐Ÿš€ 7. reduce()

Reduces array to single value.

Example:

const nums = [1,2,3,4];
const sum = nums.reduce((total,num) => total + num, 0);

console.log(sum);


Output: 10

๐Ÿงฉ 8. find()

Returns first matching element.

const users = [10,20,30,40];
const result = users.find(num => num > 20);

console.log(result);


Output: 30

๐Ÿ“‹ 9. includes()

Checks if value exists.

const fruits = ["Apple","Mango"];
console.log(fruits.includes("Apple"));


Output: true

๐Ÿ”ฅ 10. Remove Duplicates

const nums = [1,2,2,3,3];
const unique = [...new Set(nums)];
console.log(unique);


Output: [1, 2, 3]

๐Ÿ“ฆ PART 2: JavaScript Objects

๐Ÿง  11. What is an Object?

An object stores data in key-value pairs.

Example:

const person = {
name: "Deepak",
age: 25,
city: "Bengalore"
};


โšก 12. Access Object Properties

Dot Notation: console.log(person.name);

Bracket Notation: console.log(person["name"]);

๐Ÿ”ฅ 13. Add New Property

person.country = "India";
console.log(person);


โŒ 14. Delete Property

delete person.city;

๐Ÿ”„ 15. Loop Through Objects

for...in

for(let key in person){
console.log(key, person[key]);
}
  • โค 5
  • ๐Ÿ‘ 2
More from @javascript_courses
  1. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  2. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  3. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  4. Oct 4, 2026DSA Handwritten Notes
  5. Sep 28, 2026To learn web design and development from basic to advanced levels, you can follow these stโ€ฆ
  6. Sep 27, 202610 Websites Every Developer & AI Enthusiast Should Bookmark โœ… roadmap.sh โ€“ Step-by-step leโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’