What senior JavaScript interviews actually test
Junior loops drill syntax. Senior loops test whether you have been burned by production: memory leaks in SPAs, race conditions in async flows, bundle size regressions, and whether you can reason about the event loop while fixing a customer-facing bug at 4 p.m. on Friday. At Toolliyo we pair JavaScript tutorials with interview prep because many full-stack and MERN candidates know React hooks but stumble on language fundamentals when the whiteboard is plain JS.
Below are questions we hear repeatedly, with answers framed the way experienced engineers speak them—concrete, humble where appropriate, and tied to trade-offs.
Explain closures without reciting a textbook definition
Honest answer: A closure is when a function remembers variables from the scope where it was created, even after that outer function has finished. I use them for encapsulation (module pattern), callbacks that need configuration, and partial application. The production risk is accidental retention: holding references to large objects in closures attached to long-lived listeners causes memory growth in SPAs.
function createLimiter(max) {
let count = 0;
return function () {
if (count >= max) throw new Error('Rate limited');
count++;
};
}
Follow-up you should expect: "Fix a loop creating async handlers that all log the same index." Know let block scope or an IIFE binding per iteration.
How does the event loop work?
Honest answer: JavaScript runs one call stack on a single thread for your code. When you schedule async work—timers, network callbacks, promises—the runtime queues tasks. Microtasks (promise callbacks) run before the next macrotask (setTimeout, I/O). That is why Promise.resolve().then(...) runs before setTimeout(0). In Node, libuv handles I/O; in the browser, rendering and microtasks interact, so heavy synchronous work blocks paint.
I do not draw the entire loop from memory in every interview, but I explain starvation: blocking the stack with a long loop freezes UI. For CPU-heavy work I offload to Web Workers or a backend job.
var, let, const—still asked in 2025
Honest answer: Default to const, use let when rebinding, avoid var in new code because hoisting and function scope create subtle bugs. const does not freeze objects—only the binding—so immutability still requires discipline or libraries like Immer in React state.
== vs === and coercion
Honest answer: I use === almost always. I know that null == undefined is true and that [] == false is true because of coercion rules, which is why strict equality saves review time. If an interviewer asks for coercion examples, mention Number('') === 0 and that Object.is handles NaN and signed zero edge cases.
Prototypes and classes—what is really happening?
Honest answer: Classes are syntactic sugar over prototypal inheritance. Instances delegate missing properties up the prototype chain. I use classes when they improve readability for domain models; I still understand that methods on class User {} live on User.prototype. For library design, composition over deep inheritance hierarchies has served me better than mirroring Java OOP trees in JS.
Promises vs async/await
Honest answer: async/await is promise syntax sugar that reads sequentially. Errors propagate to try/catch when you await. Parallelism requires Promise.all or Promise.allSettled—awaiting in a for loop is sequential and often wrong for independent requests. I have debugged production issues from unhandled rejections when someone forgot return on an async Express handler.
// parallel
const [user, orders] = await Promise.all([
fetchUser(id),
fetchOrders(id)
]);
What is hoisting?
Honest answer: Declarations are processed before execution in their scope. function declarations hoist fully; var hoists as undefined until assignment; let/const are in the temporal dead zone until their line runs. This matters when a const helper is used before its declaration in the same block—that throws.
Deep copy vs shallow copy
Honest answer: Spread and Object.assign shallow-clone top-level properties. Nested objects still alias. For safe clones I use structuredClone in modern runtimes where appropriate, or explicit mapping for known shapes. JSON.parse/stringify drops dates, functions, and undefined—fine for DTO snapshots, dangerous for domain models.
Event delegation
Honest answer: Attach one listener on a parent and use event.target with closest selectors to handle dynamic children. Fewer listeners, better performance for long lists, survives DOM re-renders if the parent persists. In React, synthetic events and component boundaries change the pattern, but the concept still applies for vanilla widgets and legacy pages.
Module systems: ESM vs CommonJS
Honest answer: Node now supports ESM; browsers use ESM. CommonJS (require) is still common in older Node code. I know that ESM is static analyzable for tree shaking in bundlers like Vite and webpack. Mixed projects need clear package.json type and extension rules—another real-world footgun.
Performance questions that separate levels
- Explain debounce vs throttle with user search vs scroll handler examples.
- Describe how you found a layout thrashing issue (read/write DOM interleaving).
- Talk about code splitting and lazy routes in a React app you shipped.
System design flavored JS questions
Design a rate-limited API client, a pub/sub in-memory bus, or infinite scroll with cursor pagination. Seniors discuss idempotency, backoff, cancellation with AbortController, and observability. It is fine to ask clarifying questions: expected QPS, consistency needs, offline support.
How to answer when you do not know
Say what you do know, how you would find out, and a related experience. "I have not implemented a custom V8 optimization; I would profile with Chrome Performance and reduce main-thread work based on data" beats bluffing. Interviewers remember honesty plus structured thinking.
How to practice on Toolliyo
Alternate reading with speaking answers aloud for ten minutes daily. Implement one small Node script without frameworks demonstrating closures and async error handling. Pair with our MERN and Node tutorials so examples reference code you actually wrote. Record a mock answer for event loop and review if you sounded like a human teammate, not a wiki article.
JavaScript interviews reward engineers who connect language mechanics to user-visible outcomes. Learn the fundamentals deeply enough to explain trade-offs, stay current on modules and tooling, and always tie answers back to code you have shipped or debugged.