One JavaScript interview question that still confuses many developers:
What will be the output?
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 1000)
}
Output:
3
3
3
Why?
Because var is function-scoped and the loop finishes before the callback executes.
Correct version:
for (let i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 1000)
}
Output:
0
1
2
Understanding closures and scope is critical for writing reliable JavaScript.
This concept appears frequently in frontend and Node.js interviews.
What other tricky JavaScript questions have you seen in interviews?
#javascript#frontenddeveloper#webdevelopment#codinginterview
can u say this one without executing it
console.log("Starting ")
let number = 0
console.log("Initial value ", number)
setInterval(() => {
number += 1
console.log("Current value = ", number)
}, 1000)
setTimeout(() => {
console.log("After 5 seconds")
while (true) {
}
}, 5000)
JavaScript question in a frontend interview… and many developers dont know answer👀
Question:
What will be the output?
console.log([] + []);
Take a moment and think.
Most developers expect an array as output.
But the actual output is:
""
Yes — an empty string.
Why does this happen?
In JavaScript, when we use the + operator with arrays, they are converted to strings first.
[] → ""
So internally JavaScript does this:
"" + "" = ""
That’s why the result is an empty string.
Now it gets more interesting:
console.log([] + {});
Output:
"[object Object]"
Because the object converts to a string representation.
Why interviewers ask this
They want to check your understanding of:
Type coercion
JavaScript internal conversions
How the + operator works
JavaScript can look simple…
but its behavior can surprise even experienced developers.
Frontend interviews don’t just test frameworks — they test JavaScript fundamentals.
#JavaScript#FrontendDevelopment#CodingInterview#WebDevelopment#Developers#Programming
🚀 JavaScript Interview Must-Know: Closures Explained Simply
If you’re preparing for a JavaScript interview, one concept you cannot ignore is Closures.
👉 What is a Closure?
A closure is created when a function remembers variables from its lexical scope even after the outer function has finished executing.
Sounds confusing? Let’s simplify 👇
function outer() {
let count = 0;
return function inner() {
count++;
console.log(count);
};
}
const counter = outer();
counter(); // 1
counter(); // 2
counter(); // 3
👉 What’s happening here?
inner() function still has access to count
Even though outer() has already finished execution
This is called a closure
💡 Why Interviewers Love This Question?
Because it tests:
Scope understanding
Memory behavior
Real-world problem solving
🔥 Real Use Cases:
Data hiding (private variables)
Function factories
Event handlers
Callbacks & async code
👉 Pro Tip:
Closures are heavily used in frameworks like React (hooks work on similar concepts)
💬 If you’re learning JavaScript for interviews, master this concept — it appears in almost every technical round.
#JavaScript#WebDevelopment#MERNStack#Frontend#CodingInterview#100DaysOfCode#Developers#LearnToCode#IrfanMeraj
If you're preparing for JavaScript interviews…
This is ALL you need 👇
I found a PDF with 50 most asked JavaScript questions
and honestly… it covers almost everything 🔥
---
📌 Top questions you MUST know:
👉 What is JavaScript?
👉 Difference between == and ===
👉 What is closure?
👉 What is hoisting?
👉 What is event loop?
👉 What is promise & async/await?
👉 What is prototype & prototype chaining?
---
💡 Example (very common question):
👉 What is JavaScript?
✔ A lightweight, interpreted language used to create dynamic web pages
---
💡 Another important one:
👉 Difference between == and ===
✔ == → compares value
✔ === → compares value + type
---
💡 Advanced (interview favorite):
👉 What is closure?
✔ A function that remembers variables from its outer scope even after execution
---
🎯 If you prepare these 50 questions properly…
You’re already ahead of 90% candidates
---
📌 Save this before your interview
💬 Comment “JS” and I’ll share more
🔁 Share with your friends
#JavaScript#FrontendDeveloper#WebDevelopment#Coding#InterviewPreparation#TechJobs#Developers
🚀 Cracking JavaScript & React Interviews? Start Here 👇
Today I’m sharing a curated set of most-asked JavaScript & React interview questions that can literally make or break your interview 💯
📄 I’ve compiled everything into a PDF (attached) — save it, revise it, and practice consistently.
🔥 What’s inside the PDF?
✅ Core JavaScript Concepts
Closures, Hoisting, Scope
Event Loop & Callbacks
Promises vs Async/Await
This keyword & Prototypes
✅ Important React Topics
useState & useEffect deep understanding
Virtual DOM & Reconciliation
Props vs State
Controlled vs Uncontrolled Components
Performance Optimization
✅ Interview-Focused Questions
Output-based tricky questions 🧠
Real-world coding scenarios
Frequently repeated questions in interviews
💡 Why this matters?
Most candidates fail not because they don’t know coding…
but because they lack clarity in fundamentals.
👉 Interviews test your thinking, not just syntax.
🎯 How to use this PDF?
Don’t just read — try to answer first
Revise daily (15–20 mins)
Practice explaining concepts out loud
Focus on “WHY”, not just “WHAT”
💬 If you're preparing for:
#FrontendDeveloper#ReactDeveloper#JavaScriptInterviews
This will definitely help you 🚀
🙏 Special thanks to everyone who keeps pushing me to learn and grow!
📌 Comment "PDF" and I’ll make sure you don’t miss future resources like this.
#javascript#reactjs#webdevelopment#frontend#codinginterview#developers#programming#100daysofcode#learncoding#techcareer#softwaredeveloper#interviewpreparation#reactdeveloper#js
I asked this JavaScript question in a frontend interview… and many developers got it wrong. 👀
Question:
What will be the output?
console.log([] + []);
Take a moment and think.
Most developers expect an array as output.
But the actual output is:
""
Yes — an empty string.
Why does this happen?
In JavaScript, when we use the + operator with arrays, they are converted to strings first.
[] → ""
So internally JavaScript does this:
"" + "" = ""
That’s why the result is an empty string.
Now it gets more interesting:
console.log([] + {});
Output:
"[object Object]"
Because the object converts to a string representation.
Why interviewers ask this
They want to check your understanding of:
Type coercion
JavaScript internal conversions
How the + operator works
JavaScript can look simple…
but its behavior can surprise even experienced developers.
Frontend interviews don’t just test frameworks they test JavaScript fundamentals.
#JavaScript#FrontendDevelopment#CodingInterview#WebDevelopment#Developers#Programming
I asked this JavaScript question in a frontend interview… and many developers got it wrong. 👀
Question:
What will be the output?
console.log([] + []);
Take a moment and think.
Most developers expect an array as output.
But the actual output is:
""
Yes — an empty string.
Why does this happen?
In JavaScript, when we use the + operator with arrays, they are converted to strings first.
[] → ""
So internally JavaScript does this:
"" + "" = ""
That’s why the result is an empty string.
Now it gets more interesting:
console.log([] + {});
Output:
"[object Object]"
Because the object converts to a string representation.
Why interviewers ask this
They want to check your understanding of:
Type coercion
JavaScript internal conversions
How the + operator works
JavaScript can look simple…
but its behavior can surprise even experienced developers.
Frontend interviews don’t just test frameworks — they test JavaScript fundamentals.
#JavaScript#FrontendDevelopment#CodingInterview#WebDevelopment#Developers#Programming
If you're a JS interviewer testing developers, please never ask questions like this: "What will be the output? console.log([] + []);"
There's one simple correct answer - nothing
Because it's unusual code we should never see in any project. Code review should reject it and replace it with something more readable and maintainable.
If you need "[] + []" results, ask yourself: will your team understand what it solves? It's unreadable, hard-to-maintain code they'll strugle with. Even the author will struggle to maintain it after a month, let alone the team.
As developers, we should care not just that code works, but that it's readable, maintainable, and team-friendly.
So, if I highly don't recomend asking code review question like this, what better instead? Ask practical questions, for example:
1) what problem does the callback returned from useEffect solve, and when is it called?
useEffect(() => {
return => () => {} // this one
})
2) should we use"==" or "===" and why?
3) What happens if you use await inside a try/catch block versus returning the promise directly?
4) etc...
To recap: If you're an interviewer, ask about JS code used in common projects (or your project specifically). Don't hurt people with unusual theoretical questions like 'what happens with 3 + "3" - it makes no sense to memorize info we'll never use.
I asked this JavaScript question in a frontend interview… and many developers got it wrong. 👀
Question:
What will be the output?
console.log([] + []);
Take a moment and think.
Most developers expect an array as output.
But the actual output is:
""
Yes — an empty string.
Why does this happen?
In JavaScript, when we use the + operator with arrays, they are converted to strings first.
[] → ""
So internally JavaScript does this:
"" + "" = ""
That’s why the result is an empty string.
Now it gets more interesting:
console.log([] + {});
Output:
"[object Object]"
Because the object converts to a string representation.
Why interviewers ask this
They want to check your understanding of:
Type coercion
JavaScript internal conversions
How the + operator works
JavaScript can look simple…
but its behavior can surprise even experienced developers.
Frontend interviews don’t just test frameworks — they test JavaScript fundamentals.
#JavaScript#FrontendDevelopment#CodingInterview#WebDevelopment#Developers#Programming
🚀 React Interview Question Breakdown – Can You Spot the Issues?
Recently, I came across some interesting React interview questions focused on debugging and code optimization. Sharing them here 👇
🔍 Question 1: Find the issues and fix them
const items = useSelector(state => state.items);
const [filtered, setFiltered] = useState(items);
useEffect(() => {
setFiltered(items.filter(i => i.name.includes(search)));
}, []);
🔍 Question 2: Find the issues and fix them
const handleLike = async () => {
const newCount = likes + 1;
setLikes(newCount);
await api.updateLikes(newCount);
if (condition) {
setLikes(likes + 1); // Review point
}
};
#ReactJS#FrontendDevelopment#JavaScript#WebDevelopment#InterviewQuestions#ReactHooks
Top 50 JavaScript Interview Questions for Developers
Preparing for a JavaScript interview?
Here are some of the most commonly asked JavaScript questions every developer should know to crack frontend and full-stack interviews.
These questions cover important concepts like:
JavaScript execution context
Scope, hoisting, and closures
"this" keyword and binding
Promises, async/await, and the event loop
Callbacks and asynchronous programming
Prototypes and prototypal inheritance
Event delegation and event bubbling
Map, filter, reduce, and higher-order functions
Debouncing vs throttling
Deep copy vs shallow copy
Memory management and garbage collection
ES6 features like destructuring, spread, rest, and modules
Mastering these concepts will help you perform confidently in frontend, backend, and full-stack developer interviews.
Follow for more coding and interview preparation content.
#JavaScript#JavaScriptInterview#CodingInterview#FrontendDevelopment#WebDevelopment#FullStackDeveloper#SoftwareEngineer#TechInterview#LearnJavaScript#Developers
JavaScript interview questions I see being asked again and again
Although these are basics, they are often overlooked while preparing for more complex topics.
These are some of the most commonly asked JavaScript questions across interviews, especially when the focus is on fundamentals and real-world understanding.
1. What is the event loop in JavaScript?
2. What is the difference between "var", "let", and "const"?
3. What is closure and how is it used?
4. What is hoisting in JavaScript?
5. What is the difference between "==" and "==="?
6. What are promises and how do they work?
7. What is the difference between synchronous and asynchronous code?
8. What is "this" in JavaScript and how does it behave?
9. What is the difference between "map", "filter", and "reduce"?
10. What is prototypal inheritance?
11. What are higher-order functions?
12. What is debouncing and throttling?
13. What is the difference between "null" and "undefined"?
14. What is the difference between "call", "apply", and "bind"?
15. What is a polyfill? Can you write a polyfill for "bind"?
16. What is the difference between shallow copy and deep copy?
17. What is event delegation?
18. How does "setTimeout" work under the hood?
19. What is the difference between "setTimeout" and "setImmediate"?
20. What are microtasks and macrotasks?
21. What is currying in JavaScript?
22. What is memoization?
23. What is the difference between "Object.freeze" and "Object.seal"?
24. How does garbage collection work in JavaScript?
Strong fundamentals in JavaScript often make a noticeable difference in how you approach real-world problems.
Which of these do you find most interesting or tricky?
#javaScript#webdevelopment#programming#softwareengineering#InterviewPrep#interview
can u say this one without executing it console.log("Starting ") let number = 0 console.log("Initial value ", number) setInterval(() => { number += 1 console.log("Current value = ", number) }, 1000) setTimeout(() => { console.log("After 5 seconds") while (true) { } }, 5000)