The questions that come up again and again — with explanations that actually survive a follow-up, instead of answers to memorize word for word.
Most “top JavaScript interview questions” lists give you an answer to memorize and move on. That’s exactly what falls apart the moment an interviewer asks a follow-up. Here are a few that come up constantly, explained in a way that should survive one.
“What’s the difference between == and ===?”
== compares values after converting them to the same type if they differ, which is exactly why it causes surprises like '0' == 0 being true.
=== compares both value and type with no conversion, so '0' === 0 is false. The real answer interviewers want: default to === always, and only reach for == if you specifically understand and want the type conversion.
“What is a closure?”
A closure is a function that remembers the variables from the place it was created, even after that outer function has finished running.
It’s why a counter function can keep its own private count between calls — the inner function “closes over” that variable and keeps access to it, instead of it disappearing when the outer function returns.
function makeCounter() {
let count = 0;
return () => ++count;
}
const counter = makeCounter();
counter(); // 1
counter(); // 2
“What’s the difference between let, const and var?”
var is function-scoped and gets hoisted in a way that can cause confusing bugs; let and const are block-scoped, meaning they only exist inside the { } they’re declared in.
const additionally prevents the variable itself from being reassigned — though if it holds an object or array, the contents can still change. In modern code, the honest default is const, switching to let only when a value genuinely needs to be reassigned.
“What does ‘this’ refer to in JavaScript?”
this refers to whatever object called the function — and that’s determined by how the function is called, not where it’s written.
Called as obj.method(), this is obj. Called alone, this can be undefined (in strict mode) or the global object. Arrow functions are the exception: they don’t have their own this at all, they simply use whatever this was in the surrounding code.
“What is event bubbling?”
When you click an element on a page, the click event doesn’t just fire on that element — it also fires on every parent element above it, all the way up to the document, in order. That’s bubbling.
It’s why you can put one click listener on a parent container and still tell exactly which child was clicked, instead of adding a separate listener to every single item.
“What’s the difference between synchronous and asynchronous code?”
Synchronous code runs one line at a time, each line waiting for the previous one to finish.
Asynchronous code lets a slow operation — a network request, a file read — happen in the background while the rest of the program keeps running, and only comes back to handle the result once it’s ready, typically through a callback, a promise, or async/await.