let count = 0;
const interval = setInterval(() => {
count++;
console.log(count);
if (count === 5) {
clearInterval(interval);
}
}, 1000);
Output:
1
2
3
4
5
After 5, the interval is stopped.
78. What is callback hell?
Callback hell occurs when multiple asynchronous operations are nested inside one another, making code difficult to read and maintain.
Example:
getUser(user => {
getOrders(user, orders => {
getPayment(orders, payment => {
processPayment(payment, result => {
console.log(result);
});
});
});
});This creates deeply nested code.
Problems:
❌ Difficult to read
❌ Difficult to debug
❌ Difficult to maintain
❌ Error handling becomes complicated
79. How do you avoid callback hell?
Several approaches can make asynchronous code cleaner.
1. Use Promises
getUser()
.then(getOrders)
.then(getPayment)
.then(processPayment)
.catch(handleError);
2. Use async/await
async function process() {
try {
const user = await getUser();
const orders = await getOrders(user);
const payment = await getPayment(orders);
await processPayment(payment);
} catch (error) {
console.log(error);
}
}3. Break large functions into smaller functions
Instead of putting everything into one deeply nested callback, separate responsibilities into reusable functions.
Interview Tip:
For modern JavaScript, Promises and async/await are the most common solutions.
80. What are microtasks and macrotasks?
This is an important advanced JavaScript interview topic.
The JavaScript runtime has different queues for asynchronous work.
Microtasks
Examples include:
• Promise callbacks
•
queueMicrotask()• MutationObserver callbacks in browsers
Macrotasks / Tasks
Common examples include:
•
setTimeout()•
setInterval()• Some browser events
Example:
console.log("Start");
setTimeout(() => {
console.log("Timeout");
}, 0);
Promise.resolve().then(() => {
console.log("Promise");
});
console.log("End");Output:
Start
End
Promise
Timeout
Why?
After the synchronous code finishes, the runtime processes available microtasks before moving to the next task.
So:
Synchronous code
↓
Microtasks
↓
Next task / macrotask
❤️ Double Tap For Part 9
❤1
🚀 𝗪𝗶𝗽𝗿𝗼 𝗘𝗹𝗶𝘁𝗲 𝗡𝗧𝗛 & 𝗧𝘂𝗿𝗯𝗼 𝗙𝗥𝗘𝗘 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗞𝗶𝘁 💻🔥
Get access to a FREE interview preparation kit and prepare smarter for your upcoming assessment & interview rounds.
📚 Prepare For:-
✅ Technical Interview Questions
✅ Software Engineer Interview Rounds
✅ Interview Preparation Resources
🎯 Perfect for Students | Freshers | Engineering Graduates | Wipro Aspirants
🔗 𝗚𝗲𝘁 𝗙𝗥𝗘𝗘 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗞𝗶𝘁 👇:-
https://pdlink.in/4zh9E6g
🔥 Start preparing early and improve your chances of cracking the Wipro hiring process!
Get access to a FREE interview preparation kit and prepare smarter for your upcoming assessment & interview rounds.
📚 Prepare For:-
✅ Technical Interview Questions
✅ Software Engineer Interview Rounds
✅ Interview Preparation Resources
🎯 Perfect for Students | Freshers | Engineering Graduates | Wipro Aspirants
🔗 𝗚𝗲𝘁 𝗙𝗥𝗘𝗘 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗞𝗶𝘁 👇:-
https://pdlink.in/4zh9E6g
🔥 Start preparing early and improve your chances of cracking the Wipro hiring process!
𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁—𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹 𝗦𝘁𝗮𝗰𝗸 𝗗𝗲𝘃𝗲𝗹𝗼𝗽𝗲𝗿 𝘄𝗶𝘁𝗵 𝗚𝗲𝗻𝗔𝗜😍
Curriculum designed and taught by alumni from IITs & leading tech companies.
🏆 Placement Highlights:-
💰 ₹41 LPA highest salary
📈 ₹7.4 LPA average salary
🎓 2,000+ students placed
🏢 500+ partner companies
🔗 𝗔𝗽𝗽𝗹𝘆 𝗡𝗼𝘄 👇:-
https://pdlink.in/3SuUeuD
⚡ Take the first step toward your dream tech career today!
Curriculum designed and taught by alumni from IITs & leading tech companies.
🏆 Placement Highlights:-
💰 ₹41 LPA highest salary
📈 ₹7.4 LPA average salary
🎓 2,000+ students placed
🏢 500+ partner companies
🔗 𝗔𝗽𝗽𝗹𝘆 𝗡𝗼𝘄 👇:-
https://pdlink.in/3SuUeuD
⚡ Take the first step toward your dream tech career today!
🚀 JavaScript Interview Questions with Answers — Part 10
91. What is throttling?
Throttling limits how frequently a function can execute within a given time interval.
Even if an event fires many times, the function is allowed to execute at most once during each interval.
Example:
Common Uses:
• Scroll events
• Mouse movement
• Window resizing
• Continuous user interactions
Debounce vs Throttle:
Debounce → Execute after activity stops
Throttle → Execute at controlled intervals
92. What is memoization?
Memoization is an optimization technique where the result of a function is cached so that the same calculation doesn't have to be performed again.
Example:
Example Usage:
The first call performs the calculation.
The second call can use the cached result.
Benefits:
✅ Faster repeated calculations
✅ Avoids unnecessary work
Drawback:
❌ Uses additional memory for cached results.
93. What is currying?
Currying transforms a function that takes multiple arguments into a sequence of functions that each take one argument.
Normal Function:
Curried Function:
Usage:
Output:
Arrow Function Version:
Common Uses:
• Functional programming
• Creating reusable functions
• Partial application
• Configuration-based functions
94. What is prototype inheritance?
JavaScript uses objects as the foundation of its inheritance system.
Objects can access properties and methods through their prototype chain.
Example:
Although dog doesn't directly contain speak(), it can access the method through its prototype.
Prototype Chain:
dog
↓
animal
↓
Object.prototype
↓
null
JavaScript searches this chain when a property isn't found directly on the object.
95. What is prototypal inheritance?
Prototypal inheritance is JavaScript's mechanism for allowing one object to inherit behavior from another object through the prototype chain.
Example:
Here:
student has its own study() method.
greet() comes from its prototype, person.
96. What are classes in JavaScript?
Classes provide a cleaner syntax for creating objects and implementing object-oriented programming patterns.
Classes were introduced in ES6.
Example:
91. What is throttling?
Throttling limits how frequently a function can execute within a given time interval.
Even if an event fires many times, the function is allowed to execute at most once during each interval.
Example:
function throttle(callback, delay) {
let lastTime = 0;
return function(...args) {
const now = Date.now();
if (now - lastTime >= delay) {
lastTime = now;
callback.apply(this, args);
}
};
}Common Uses:
• Scroll events
• Mouse movement
• Window resizing
• Continuous user interactions
Debounce vs Throttle:
Debounce → Execute after activity stops
Throttle → Execute at controlled intervals
92. What is memoization?
Memoization is an optimization technique where the result of a function is cached so that the same calculation doesn't have to be performed again.
Example:
function memoize(fn) {
const cache = new Map();
return function(n) {
if (cache.has(n)) {
return cache.get(n);
}
const result = fn(n);
cache.set(n, result);
return result;
};
}Example Usage:
function square(n) {
console.log("Calculating...");
return n * n;
}
const memoizedSquare = memoize(square);
console.log(memoizedSquare(5));
console.log(memoizedSquare(5));The first call performs the calculation.
The second call can use the cached result.
Benefits:
✅ Faster repeated calculations
✅ Avoids unnecessary work
Drawback:
❌ Uses additional memory for cached results.
93. What is currying?
Currying transforms a function that takes multiple arguments into a sequence of functions that each take one argument.
Normal Function:
function add(a, b, c) {
return a + b + c;
}
console.log(add(1, 2, 3));Curried Function:
function add(a) {
return function(b) {
return function(c) {
return a + b + c;
};
};
}Usage:
console.log(add(1)(2)(3));
Output:
6
Arrow Function Version:
const add = a => b => c => a + b + c;
Common Uses:
• Functional programming
• Creating reusable functions
• Partial application
• Configuration-based functions
94. What is prototype inheritance?
JavaScript uses objects as the foundation of its inheritance system.
Objects can access properties and methods through their prototype chain.
Example:
const animal = {
speak() {
console.log("Animal speaks");
}
};
const dog = Object.create(animal);
dog.speak();Although dog doesn't directly contain speak(), it can access the method through its prototype.
Prototype Chain:
dog
↓
animal
↓
Object.prototype
↓
null
JavaScript searches this chain when a property isn't found directly on the object.
95. What is prototypal inheritance?
Prototypal inheritance is JavaScript's mechanism for allowing one object to inherit behavior from another object through the prototype chain.
Example:
const person = {
greet() {
console.log("Hello");
}
};
const student = Object.create(person);
student.study = function() {
console.log("Studying");
};
student.greet();
student.study();Here:
student has its own study() method.
greet() comes from its prototype, person.
96. What are classes in JavaScript?
Classes provide a cleaner syntax for creating objects and implementing object-oriented programming patterns.
Classes were introduced in ES6.
Example:
❤2
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
greet() {
console.log(`Hello, I am ${this.name}`);
}
}
const person = new Person("Deepak", 25);
person.greet();Output:
Hello, I am Deepak
Important:
JavaScript classes are built on top of JavaScript's prototype-based inheritance.
Classes Support:
• Constructors
• Methods
• Inheritance
• Getters and setters
• Static methods
• Private fields
97. What is garbage collection?
Garbage collection is the automatic process of identifying and reclaiming memory that is no longer reachable or needed by a JavaScript program.
Developers don't normally manually free JavaScript objects.
Example:
let user = {
name: "Deepak"
};
user = null;If the original object is no longer reachable from the program, it can eventually become eligible for garbage collection.
Important:
Garbage collection timing is determined by the JavaScript engine. You cannot normally force it from standard JavaScript code.
98. How does JavaScript manage memory?
JavaScript automatically manages memory using mechanisms such as:
1. Memory allocation
2. Program execution
3. Garbage collection
Simplified Process:
Create value
↓
Memory allocated
↓
Program uses value
↓
Value becomes unreachable
↓
Garbage collector
↓
Memory can be reclaimed
What is a Memory Leak?
A memory leak occurs when a program unintentionally keeps references to objects that it no longer needs.
Common Causes:
• Unremoved event listeners
• Unnecessary global variables
• Timers that aren't cleared
• Large objects retained in closures
• Growing caches without limits
Example:
const cache = [];
function addData(data) {
cache.push(data);
}
If cache keeps growing indefinitely, it can consume increasing amounts of memory.
99. What are CommonJS and ES Modules?
Both are module systems used in JavaScript applications.
CommonJS
Commonly associated with Node.js and uses require() and module.exports.
// math.js
function add(a, b) {
return a + b;
}
module.exports = { add };
Import:
const { add } = require("./math");ES Modules
The standardized JavaScript module system uses import and export.
// math.js
export function add(a, b) {
return a + b;
}
Import:
import { add } from "./math.js";Modern JavaScript development commonly uses ES Modules, while CommonJS remains important when working with existing Node.js projects.
100. What are the latest JavaScript features introduced in ES2025 and beyond?
JavaScript continues to evolve through yearly ECMAScript releases.
For ES2025 (ECMAScript 2025), notable standardized additions include:
🔥 Iterator Helpers
Methods such as:
iterator.map(...)iterator.filter(...)iterator.take(...)allow lazy processing of iterator values.
🔥 Iterator.from()
Allows an object to be converted into an iterator.
const iterator = Iterator.from([1, 2, 3]);
🔥 Set Methods
Modern Set operations include methods such as:
•
union()•
intersection()•
difference()•
symmetricDifference()Example:
const a = new Set([1, 2, 3]);
const b = new Set([3, 4, 5]);
const result = a.union(b);
console.log(result);
❤2
🔥 Regular Expression Improvements
ES2025 also introduced improvements to regular expressions, including support for enhanced Unicode-related matching capabilities.
🔥 Promise.try()
⚠️ Important Interview Point
JavaScript features are standardized through the ECMAScript specification, and browser/Node.js support can vary by feature and version.
So when discussing "latest JavaScript," distinguish between:
Standardized features
→ Officially included in an ECMAScript release.
Proposed features
→ Still moving through the TC39 proposal process.
Runtime support
→ Whether a particular browser or Node.js version actually supports the feature.
Double Tap ❤️ For More
ES2025 also introduced improvements to regular expressions, including support for enhanced Unicode-related matching capabilities.
🔥 Promise.try()
Promise.try() provides a convenient way to turn a synchronous function call into a Promise-based operation.Promise.try(() => {
return someFunction();
});⚠️ Important Interview Point
JavaScript features are standardized through the ECMAScript specification, and browser/Node.js support can vary by feature and version.
So when discussing "latest JavaScript," distinguish between:
Standardized features
→ Officially included in an ECMAScript release.
Proposed features
→ Still moving through the TC39 proposal process.
Runtime support
→ Whether a particular browser or Node.js version actually supports the feature.
Double Tap ❤️ For More
❤2
🚀 𝗙𝗥𝗘𝗘 𝗗𝗮𝘁𝗮 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 𝗖𝗼𝘂𝗿𝘀𝗲! 📊
Here’s a great chance to learn valuable skills and earn a FREE Certificate 🎓
✅ Beginner-friendly
✅ Learn Data Analytics skills
✅ Free certification
✅ Boost your resume & LinkedIn profile
✅ Great for students & job seekers
𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇 :-
https://pdlink.in/4qn5q94
📌 Start learning today & upgrade your career!
Here’s a great chance to learn valuable skills and earn a FREE Certificate 🎓
✅ Beginner-friendly
✅ Learn Data Analytics skills
✅ Free certification
✅ Boost your resume & LinkedIn profile
✅ Great for students & job seekers
𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇 :-
https://pdlink.in/4qn5q94
📌 Start learning today & upgrade your career!
𝗙𝗥𝗘𝗘 𝗚𝗲𝗻𝗔𝗜 + 𝗖𝗹𝗮𝘂𝗱𝗲 𝗢𝗻𝗹𝗶𝗻𝗲 𝗠𝗮𝘀𝘁𝗲𝗿𝗰𝗹𝗮𝘀𝘀😍
Learn how to use 25+ powerful AI tools to automate your work, create professional content and save hours every week!
🎯 Perfect For:-
Freelancers • Working Professionals • Business Owners • Self-Employed Individuals
💡 No technical knowledge or prior experience required!
🔗 𝗥𝗲𝗴𝗶𝘀𝘁𝗲𝗿 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘 👇:-
https://pdlinks.in/ai
⚡ Start using AI smarter—limited slots available!
Learn how to use 25+ powerful AI tools to automate your work, create professional content and save hours every week!
🎯 Perfect For:-
Freelancers • Working Professionals • Business Owners • Self-Employed Individuals
💡 No technical knowledge or prior experience required!
🔗 𝗥𝗲𝗴𝗶𝘀𝘁𝗲𝗿 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘 👇:-
https://pdlinks.in/ai
⚡ Start using AI smarter—limited slots available!
❤3
🎓 𝐀𝐜𝐜𝐞𝐧𝐭𝐮𝐫𝐞 𝐅𝐑𝐄𝐄 𝐂𝐞𝐫𝐭𝐢𝐟𝐢𝐜𝐚𝐭𝐢𝐨𝐧 𝐂𝐨𝐮𝐫𝐬𝐞𝐬 😍
Boost your skills with 100% FREE certification courses from Accenture!
📚 FREE Courses Offered:
1️⃣ Data Processing and Visualization
2️⃣ Exploratory Data Analysis
3️⃣ SQL Fundamentals
4️⃣ Python Basics
5️⃣ Acquiring Data
𝐋𝐢𝐧𝐤 👇:-
https://pdlink.in/4yJKnBy
✅ Learn Online | 📜 Get Certified
Boost your skills with 100% FREE certification courses from Accenture!
📚 FREE Courses Offered:
1️⃣ Data Processing and Visualization
2️⃣ Exploratory Data Analysis
3️⃣ SQL Fundamentals
4️⃣ Python Basics
5️⃣ Acquiring Data
𝐋𝐢𝐧𝐤 👇:-
https://pdlink.in/4yJKnBy
✅ Learn Online | 📜 Get Certified
𝗠𝗶𝗰𝗿𝗼𝘀𝗼𝗳𝘁 𝗮𝗻𝗱 𝗟𝗶𝗻𝗸𝗲𝗱𝗜𝗻 𝗙𝗥𝗘𝗘 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻𝘀🎓
Want to strengthen your resume with career-focused professional skills? Explore these free learning paths from Microsoft and LinkedIn.
🔥 Courses Available:
📌 Project Management
📊 Business Analysis
💻 System Administration
📈 Data Analysis
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘 👇:-
https://pdlinks.in/micrlink
💡 Learn → Get Certified → Upgrade Your Resume → Boost Your Career
Want to strengthen your resume with career-focused professional skills? Explore these free learning paths from Microsoft and LinkedIn.
🔥 Courses Available:
📌 Project Management
📊 Business Analysis
💻 System Administration
📈 Data Analysis
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘 👇:-
https://pdlinks.in/micrlink
💡 Learn → Get Certified → Upgrade Your Resume → Boost Your Career
𝗚𝗼𝗼𝗴𝗹𝗲 𝗙𝗥𝗘𝗘 𝗔𝗜 & 𝗠𝗮𝗰𝗵𝗶𝗻𝗲 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗖𝗼𝘂𝗿𝘀𝗲𝘀 🚀
Explore Google Cloud learning resources covering AI/ML fundamentals through practical and advanced concepts.
🚀 Learn AI → Practice ML → Build Skills → Become Career Ready
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘 👇:-
https://pdlinks.in/eb6
🚀 Learn AI → Practice ML → Build Skills → Become Career Ready
Explore Google Cloud learning resources covering AI/ML fundamentals through practical and advanced concepts.
🚀 Learn AI → Practice ML → Build Skills → Become Career Ready
🔗 𝗘𝗻𝗿𝗼𝗹𝗹 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘 👇:-
https://pdlinks.in/eb6
🚀 Learn AI → Practice ML → Build Skills → Become Career Ready
Free Resources to Learn Each Tech Stack 🧠✨
No excuses. Everything you need is free!
1. Frontend Development
❯ freeCodeCamp.org – HTML, CSS, JS
❯ MDN Web Docs – Best docs for web tech
❯ Frontend Mentor – Real-world challenges
❯ CSS Tricks – CSS deep dives
❯ YouTube: Kevin Powell, Web Dev Simplified
—
2. Backend Development
❯ Node.js Docs
❯ Django Girls Tutorial
❯ The Odin Project – Full Stack
❯ Spring Boot Guides
❯ YouTube: Amigoscode, CodeWithHarry (Hindi), Tech With Tim
—
3. Full-Stack Development
❯ Full Stack Open – React + Node
❯ The Odin Project
❯ CS50 Web – Harvard’s free course
❯ YouTube: Traversy Media, Clever Programmer, JavaScript Mastery
—
4. Data Analytics
❯ Kaggle Learn – Python, SQL, Viz
❯ Maven Analytics – Free Power BI/Tableau projects
❯ Google Data Analytics Course
❯ W3Schools SQL
❯ YouTube: Luke Barousse, Alex The Analyst
—
5. Machine Learning
❯ Google’s ML Crash Course
❯ fast.ai – Deep learning made easy
❯ Kaggle Courses – End-to-end ML
❯ Coursera – Andrew Ng
❯ YouTube: StatQuest, Krish Naik, Codebasics
—
6. DevOps
❯ KodeKloud – Docker, K8s, Ansible
❯ Learn Git Branching
❯ Katacoda – Interactive Linux & DevOps
❯ Roadmap.sh – What to learn
❯ YouTube: TechWorld with Nana, Nana Janashia
No excuses. Everything you need is free!
1. Frontend Development
❯ freeCodeCamp.org – HTML, CSS, JS
❯ MDN Web Docs – Best docs for web tech
❯ Frontend Mentor – Real-world challenges
❯ CSS Tricks – CSS deep dives
❯ YouTube: Kevin Powell, Web Dev Simplified
—
2. Backend Development
❯ Node.js Docs
❯ Django Girls Tutorial
❯ The Odin Project – Full Stack
❯ Spring Boot Guides
❯ YouTube: Amigoscode, CodeWithHarry (Hindi), Tech With Tim
—
3. Full-Stack Development
❯ Full Stack Open – React + Node
❯ The Odin Project
❯ CS50 Web – Harvard’s free course
❯ YouTube: Traversy Media, Clever Programmer, JavaScript Mastery
—
4. Data Analytics
❯ Kaggle Learn – Python, SQL, Viz
❯ Maven Analytics – Free Power BI/Tableau projects
❯ Google Data Analytics Course
❯ W3Schools SQL
❯ YouTube: Luke Barousse, Alex The Analyst
—
5. Machine Learning
❯ Google’s ML Crash Course
❯ fast.ai – Deep learning made easy
❯ Kaggle Courses – End-to-end ML
❯ Coursera – Andrew Ng
❯ YouTube: StatQuest, Krish Naik, Codebasics
—
6. DevOps
❯ KodeKloud – Docker, K8s, Ansible
❯ Learn Git Branching
❯ Katacoda – Interactive Linux & DevOps
❯ Roadmap.sh – What to learn
❯ YouTube: TechWorld with Nana, Nana Janashia
❤5
𝗧𝗼𝗽 𝗜𝗻-𝗗𝗲𝗺𝗮𝗻𝗱 𝗦𝗸𝗶𝗹𝗹𝘀 𝘁𝗼 𝗙𝘂𝘁𝘂𝗿𝗲-𝗣𝗿𝗼𝗼𝗳 𝗬𝗼𝘂𝗿 𝗖𝗮𝗿𝗲𝗲𝗿 😍
🔥 Skills Worth Learning:
⛓️ Blockchain
☁️ Cloud Computing
♾️ DevOps Engineering
🤖 Artificial Intelligence & Machine Learning
📊 Data Science & Analytics
🔐 Cybersecurity
🎯 Leadership & Communication
𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:-
https://pdlinks.in/i89
Don’t just collect certificates — build projects, gain practical experience and showcase your skills on your resume & LinkedIn.
🔥 Skills Worth Learning:
⛓️ Blockchain
☁️ Cloud Computing
♾️ DevOps Engineering
🤖 Artificial Intelligence & Machine Learning
📊 Data Science & Analytics
🔐 Cybersecurity
🎯 Leadership & Communication
𝗘𝗻𝗿𝗼𝗹𝗹 𝗙𝗼𝗿 𝗙𝗥𝗘𝗘👇:-
https://pdlinks.in/i89
Don’t just collect certificates — build projects, gain practical experience and showcase your skills on your resume & LinkedIn.