🚀 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:
Access Elements:
Output: Apple
Important: Array indexing starts from 0.
⚡ 2. Creating Arrays
Method 1:
Method 2:
🔥 3. Array Methods
push() Adds element at the end.
Output: [1, 2, 3]
pop() Removes last element.
unshift() Adds element at beginning.
shift() Removes first element.
🔄 4. Loop Through Arrays
for Loop
for...of
🎯 5. map()
Creates a new array by transforming elements.
Example:
Output: [2, 4, 6]
🔥 6. filter()
Returns elements matching condition.
Example:
Output: [2, 4]
🚀 7. reduce()
Reduces array to single value.
Example:
Output: 10
🧩 8. find()
Returns first matching element.
Output: 30
📋 9. includes()
Checks if value exists.
Output: true
🔥 10. Remove Duplicates
Output: [1, 2, 3]
📦 PART 2: JavaScript Objects
🧠 11. What is an Object?
An object stores data in key-value pairs.
Example:
⚡ 12. Access Object Properties
Dot Notation:
Bracket Notation:
🔥 13. Add New Property
❌ 14. Delete Property
🔄 15. Loop Through Objects
for...in
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]);
}❤4👍2
🎯 16. Object.keys()
Returns all keys.
Output: ["name","age"]
🚀 17. Object.values()
Returns all values.
Output: ["Deepak",25]
🔥 18. Object.entries()
Returns key-value pairs.
Output: [["name","Deepak"], ["age",25]]
📦 19. Destructuring Objects
Extract values easily.
⚡ 20. Spread Operator
Copy objects.
🎯 Real Interview Example
Array of Objects
Output: John
⭐ Most Important Topics For Interviews
🔥 Arrays
🔥 Objects
🔥 map()
🔥 filter()
🔥 reduce()
🔥 Destructuring
🔥 Spread Operator
🔥 Object.keys()
🔥 Object.values()
🔥 Array of Objects
📝 Mini Practice Questions
Easy:
✅ Find largest number in array,
✅ Sum all array elements,
✅ Count array length
Medium:
✅ Remove duplicates,
✅ Find second largest number,
✅ Reverse array
Advanced:
✅ Group objects by property,
✅ Custom map() method,
✅ Flatten nested arrays
Double Tap ❤️ For More
Returns all keys.
console.log(Object.keys(person));Output: ["name","age"]
🚀 17. Object.values()
Returns all values.
console.log(Object.values(person));Output: ["Deepak",25]
🔥 18. Object.entries()
Returns key-value pairs.
console.log(Object.entries(person));Output: [["name","Deepak"], ["age",25]]
📦 19. Destructuring Objects
Extract values easily.
const person = { name:"Deepak", age:25 };
const { name, age } = person;⚡ 20. Spread Operator
Copy objects.
const person = { name:"Deepak" };
const updated = {...person, city:"Pune" };🎯 Real Interview Example
Array of Objects
const employees = [
{ id:1, name:"John" },
{ id:2, name:"Mike" }
];
console.log(employees[0].name);
Output: John
⭐ Most Important Topics For Interviews
🔥 Arrays
🔥 Objects
🔥 map()
🔥 filter()
🔥 reduce()
🔥 Destructuring
🔥 Spread Operator
🔥 Object.keys()
🔥 Object.values()
🔥 Array of Objects
📝 Mini Practice Questions
Easy:
✅ Find largest number in array,
✅ Sum all array elements,
✅ Count array length
Medium:
✅ Remove duplicates,
✅ Find second largest number,
✅ Reverse array
Advanced:
✅ Group objects by property,
✅ Custom map() method,
✅ Flatten nested arrays
Double Tap ❤️ For More
❤2👍2
🎓 𝗜𝗜𝗠 𝗙𝗥𝗘𝗘 𝗢𝗻𝗹𝗶𝗻𝗲 𝗖𝗼𝘂𝗿𝘀𝗲𝘀 𝟮𝟬𝟮𝟲 🚀
Here's your chance to access FREE online courses offered by IIMs and earn valuable certifications! 🌟
📚 Popular Learning Areas:
✅ Business Management
✅ Digital Marketing
✅ Leadership Skills
✅ Data Analytics
✅ Finance & Accounting
✅ Operations Management
✅ Entrepreneurship
✅ Strategic Management
💫IIMs offer a variety of online learning opportunities through platforms like SWAYAM and their digital learning initiatives.
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:
https://pdlink.in/4xsgu7T
⏳ Enroll Now & Start Learning for FREE!
Here's your chance to access FREE online courses offered by IIMs and earn valuable certifications! 🌟
📚 Popular Learning Areas:
✅ Business Management
✅ Digital Marketing
✅ Leadership Skills
✅ Data Analytics
✅ Finance & Accounting
✅ Operations Management
✅ Entrepreneurship
✅ Strategic Management
💫IIMs offer a variety of online learning opportunities through platforms like SWAYAM and their digital learning initiatives.
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:
https://pdlink.in/4xsgu7T
⏳ Enroll Now & Start Learning for FREE!
👍5❤1
Which method is used to add an element at the end of an array?
Anonymous Quiz
15%
A) pop()
67%
B) push()
15%
C) shift()
4%
D) unshift()
👍4😭2
Which method is used to create a new array containing only elements that match a condition?
Anonymous Quiz
9%
A) reduce()
19%
B) find()
58%
C) filter()
13%
D) push()
👍5
How do you access the name property of the object below?
const person = { name: "Deepak",age: 25};
const person = { name: "Deepak",age: 25};
Anonymous Quiz
9%
A) person->name
22%
B) person[name]
41%
C) person.name
28%
D) Both B and C
❤3👍2
What will be the output?
JavaScript
const nums = [1, 2, 3, 4]; const sum = nums.reduce( (total, num) => total + num, 0 ); console.log(sum);
JavaScript
const nums = [1, 2, 3, 4]; const sum = nums.reduce( (total, num) => total + num, 0 ); console.log(sum);
Anonymous Quiz
22%
[1,2,3,4]
13%
4
56%
10
8%
12
❤7👍2
🎓𝟱 𝗙𝗥𝗘𝗘 𝗜𝗕𝗠 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝘂𝗿𝘀𝗲𝘀 𝟮𝟬𝟮𝟲 🚀
IBM SkillsBuild offers FREE online courses, digital credentials, and career-focused learning paths to help students and professionals become job-ready. 🌟
✔️ 100% Free Learning Resources
✔️ Industry-Recognized Digital Badges
✔️ Self-Paced Learning
✔️ Hands-On Projects & Assessments
✔️ Resume & LinkedIn Profile Enhancement
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:
https://pdlink.in/4vPMTDO
⏳ Start Learning Today & Boost Your Career!
IBM SkillsBuild offers FREE online courses, digital credentials, and career-focused learning paths to help students and professionals become job-ready. 🌟
✔️ 100% Free Learning Resources
✔️ Industry-Recognized Digital Badges
✔️ Self-Paced Learning
✔️ Hands-On Projects & Assessments
✔️ Resume & LinkedIn Profile Enhancement
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:
https://pdlink.in/4vPMTDO
⏳ Start Learning Today & Boost Your Career!
👍3
20 JavaScript Project Ideas🔥:
🔹Countdown Timer
🔹Digital Clock
🔹Calculator App
🔹Password Generator
🔹Random Quote Generator
🔹Image Slider
🔹Sticky Notes App
🔹Typing Speed Test
🔹Expense Tracker
🔹Currency Converter
🔹BMI Calculator
🔹Pomodoro Timer
🔹Form Validation Project
🔹Memory Card Game
🔹URL Shortener UI
🔹Kanban Board
🔹GitHub Profile Finder
🔹Age Calculator
🔹Search Filter App
🔹Animated Login Page
Do not forget to React ❤️ to this message for more content like this
Thanks for joining ❤️🙏
🔹Countdown Timer
🔹Digital Clock
🔹Calculator App
🔹Password Generator
🔹Random Quote Generator
🔹Image Slider
🔹Sticky Notes App
🔹Typing Speed Test
🔹Expense Tracker
🔹Currency Converter
🔹BMI Calculator
🔹Pomodoro Timer
🔹Form Validation Project
🔹Memory Card Game
🔹URL Shortener UI
🔹Kanban Board
🔹GitHub Profile Finder
🔹Age Calculator
🔹Search Filter App
🔹Animated Login Page
Do not forget to React ❤️ to this message for more content like this
Thanks for joining ❤️🙏
❤14👍4
☁️ Backend Engineering Tips
✅ Validate all user input
✅ Log errors properly
✅ Use environment variables
✅ Design scalable APIs
✅ Cache frequent requests
✅ Write clean documentation
✅ Validate all user input
✅ Log errors properly
✅ Use environment variables
✅ Design scalable APIs
✅ Cache frequent requests
✅ Write clean documentation
👍1
𝗗𝗮𝘁𝗮 𝗦𝗰𝗶𝗲𝗻𝗰𝗲 𝗙𝗥𝗘𝗘 𝗢𝗻𝗹𝗶𝗻𝗲 𝗠𝗮𝘀𝘁𝗲𝗿𝗰𝗹𝗮𝘀𝘀 😍
💫 This Masterclass will help you build a strong foundation in Data Science
💫Kickstart Your Data Science Career.Join this Masterclass for an expert-led session on Data Science
Eligibility :- Students ,Freshers & Working Professionals
𝗥𝗲𝗴𝗶𝘀𝘁𝗲𝗿 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇 :-
https://pdlink.in/4uBFtDb
( Limited Slots ..Hurry Up )
Date & Time :- 19th June 2026 , 7:00 PM
💫 This Masterclass will help you build a strong foundation in Data Science
💫Kickstart Your Data Science Career.Join this Masterclass for an expert-led session on Data Science
Eligibility :- Students ,Freshers & Working Professionals
𝗥𝗲𝗴𝗶𝘀𝘁𝗲𝗿 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇 :-
https://pdlink.in/4uBFtDb
( Limited Slots ..Hurry Up )
Date & Time :- 19th June 2026 , 7:00 PM
Fullstack Developer Skills & Technologies
👍17❤3
📊 𝗖𝗶𝘀𝗰𝗼 𝗙𝗥𝗘𝗘 𝗗𝗮𝘁𝗮 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 | 𝗘𝗻𝗿𝗼𝗹𝗹 𝗡𝗼𝘄! 🚀
🚀 Data Analytics is one of the most in-demand career paths in 2026
🔥 Program Benefits:
✅ FREE Certification
✅ Self-Paced Learning
✅ Beginner Friendly
✅ Industry-Relevant Curriculum
✅ Resume & LinkedIn Booster
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:
https://pdlink.in/4gaeVVV
📢 Share with friends who want to start a career in Data Analytics!
🚀 Data Analytics is one of the most in-demand career paths in 2026
🔥 Program Benefits:
✅ FREE Certification
✅ Self-Paced Learning
✅ Beginner Friendly
✅ Industry-Relevant Curriculum
✅ Resume & LinkedIn Booster
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:
https://pdlink.in/4gaeVVV
📢 Share with friends who want to start a career in Data Analytics!
👍6❤2