Interview Prep
JavaScript interview questions and how to answer them
JavaScript interviews test the fundamentals that a lot of developers assume they know but haven't thought about deeply. Closures, the event loop, prototype chains. These come up at every level.
PrepVault surfaces the questions you need and tracks your prep by role. Free to start.
JavaScript interview questions and how to answer them
How do JavaScript generators enable lazy evaluation, and how would you use a generator to implement an infinite sequence that a consumer can pull from on demand?
Generators are suspended coroutines - state persists across yield. Pull-based: computation happens on consumer .next() call. Infinite sequences only compute what is consumed. Chained generators avoid intermediate array allocations. break inside for...of triggers generator cleanup via return()
How would you use object destructuring to make code easier to read?
Destructuring extracts properties into variables. It reduces repeated object.property access. Property names must match unless renamed. Default values can be provided. Destructuring improves readability when used clearly
How does package.json "type" affect JavaScript module interpretation in Node.js?
type module makes .js ESM. missing type defaults to CommonJS. .mjs is always ESM. .cjs is always CommonJS
What is the temporal dead zone and how does it relate to scope?
let and const initialization. ReferenceError before declaration. safer than var hoisting
What does this bind example log?
bind fixes this. returns new function. safe detached method
Why can too many concurrent Promises be a performance problem?
Promises are not threads. downstream limits. bounded concurrency
What are live bindings in ES modules?
not copied values. exporter owns binding. shared mutable risk
What practical problem does snapshot testing try to solve?
Snapshot tests capture rendered output. Snapshots detect unexpected UI changes. They are useful for stable components. Large snapshots become difficult to review. Snapshots should not replace behavior testing
How does JavaScript compare objects for equality?
reference equality. same contents not enough. domain-specific comparison
How would you design and instrument a performance budget system for a JavaScript-heavy application, and what metrics would you track at the build, runtime, and user-experience layers?
build-time budgets catch size regressions before deploy. Long Tasks API detects main-thread blocking at runtime. Core Web Vitals (LCP, INP, CLS) represent user-perceived quality. policy on block-vs-alert determines whether the budget is respected
Common mistakes
- Hand-waving closures and the event loop
- Mixing up the equality and coercion edge cases
- Not explaining async behavior precisely
What interviewers weigh
- Command of closures, scope, and prototypes
- How you reason about async code
- Whether you know the why, not just the syntax