JavaScript Array Methods x Hera Pheri

Search for a command to run...

No comments yet. Be the first to comment.
When working on Node.js, React, Next.js, or any modern application, one of the first things you'll create is a .env file. It stores everything from database credentials to API keys and authentication

When you type www.aniketdey.in into your browser and hit Enter, it feels like magic. In a split second, a website appears. But behind the scenes, there’s a frantic game of "connect the dots" happening. The big question is: How does your browser know ...

If you’ve ever worked on a college project or a design file, you know the feeling. You finish your work, save it, and then realize you need one tiny change. Suddenly, your folder looks like this: project.zip 📦 project_final.zip ✅ project_final_v2...

What is Git? At its heart, Git is a Distributed Version Control System (VCS). Think of it as a sophisticated "undo" button for your entire project. Unlike a standard "Save" button that overwrites your file, Git keeps a record of every change you make...

Have you ever wondered how clicking a link opens a webpage in seconds? Like, you hit enter on youtube.com, and boom videos. But what’s really happening behind that click is a fascinating digital relay race. Let’s decode the backbone of the internet u...

A hot summer day in Mumbai, a small chawl, and three unemployed men – Baburao Ganpatrao Apte (Babu Bhaiya), Raju, and Shyam. Their lives were already a mess of Hera Pheri, when one day, a brilliant idea struck – learning JavaScript!
Babu Bhaiya said, “How do we double our money? We must learn this!”
Raju replied, “It’s all about array method, Babu Bhaiya. If we master this, our life is set!”
Shyam grabbed a laptop, and all three dived into the magical world of JavaScript arrays.
push() – Paisa Add Karo Re Baba!Raju started explaining, “push() is like adding money to our savings.”
let money = ['₹500', '₹1000'];
money.push('₹2000');
console.log(money); // ['₹500', '₹1000', '₹2000']
Babu Bhaiya exclaimed, “Arre wah! This is a great scheme! Double, double!”
pop() – Paisa Gaya, System Lucha!When Babu Bhaiya went to the ATM, the system behaved like pop() and removed the last amount.
money.pop();
console.log(money); // ['₹500', '₹1000']
Shyam laughed, “Babu Bhaiya, this method is just like your wallet – money disappears instantly!”
shift() – Babu Bhaiya Ka UdhaarRaju said, “We must clear Babu Bhaiya’s debts first. That’s why we use shift().”
let debts = ['Raju ka ₹500', 'Shyam ka ₹1000', 'Bank ka ₹2000'];
debts.shift();
console.log(debts); // ['Shyam ka ₹1000', 'Bank ka ₹2000']
Babu Bhaiya shouted, “Arre! Why is my money always the first to go?”
unshift() – Naya Loan Aya Hai!When Raju took a new loan, it got added to the beginning using unshift().
debts.unshift('Raju ka naya ₹3000');
console.log(debts); // ['Raju ka naya ₹3000', 'Shyam ka ₹1000', 'Bank ka ₹2000']
Shyam smirked, “Raju, your loans are increasing like an infinite array!”
map() – Idea Chhapo!Babu Bhaiya had an idea: “Let’s multiply our money by 10!”
let money = [100, 200, 300];
let doubleMoney = money.map(amount => amount * 10);
console.log(doubleMoney); // [1000, 2000, 3000]
Raju shouted, “Arre Babu Bhaiya! This is the real double-your-money scheme!”
filter() – Sirf Munafa!Shyam decided to filter out only profit transactions.
let transactions = [-100, 500, -200, 1000, -50];
let profitOnly = transactions.filter(amount => amount > 0);
console.log(profitOnly); // [500, 1000]
Babu Bhaiya was impressed, “Just focus on profits! Who cares about losses?!”
reduce() – Sabko Ek Kar Dala!Babu Bhaiya said, “Let’s calculate the total earnings for the year.”
let money = [500, 1000, 1500, 2000];
let total = money.reduce((acc, curr) => acc + curr, 0);
console.log(total); // 5000
Shyam sighed, “Babu Bhaiya, your total money is just ₹5000!”
Babu Bhaiya: “What?! Such a small total? System looted, re baba!”
find() – Raju Ka Loan Kahan Gaya?Shyam asked, “Which loan belongs to Raju?”
let loans = [{name: 'Raju', amount: 1000}, {name: 'Shyam', amount: 2000}];
let rajuLoan = loans.find(loan => loan.name === 'Raju');
console.log(rajuLoan); // {name: 'Raju', amount: 1000}
Raju laughed, “Arre! My loan was found so easily!”
some() – Koi Bhi Amir Hai Kya?Babu Bhaiya wondered, “Check if anyone in the chawl is rich.”
let bankBalance = [500, 1000, 1500, 10000];
let isAnyoneRich = bankBalance.some(amount => amount >= 10000);
console.log(isAnyoneRich); // true
Raju: “Yes, Babu Bhaiya, there’s one person who is rich!”
Babu Bhaiya: “Who is he?! Where’s his money?!”
every() – Sab Gareeb Hain Kya?Shyam asked, “Are all chawl residents poor?”
let bankBalance = [500, 1000, 1500, 2000];
let allPoor = bankBalance.every(amount => amount < 10000);
console.log(allPoor); // true
Babu Bhaiya sighed, “Everyone’s in the same boat, re baba!”
And just like that, Babu Bhaiya, Raju, and Shyam mastered JavaScript array methods! But… they were still broke!
Babu Bhaiya concluded with his legendary dialogue:
“System set hai re baba! Only money is missing!”

And that, dear friends, was the Hera Pheri x JavaScript Arrays story! 😂