Interview Prep

JavaScript

250 questions across 21 categories

Interview Me →

50 of 50 questions

#CategoryQuestionAnswer★
1Event LoopExplain the JavaScript event loop, call stack, task queue, and microtask queue. What is the order of execution?
Click row to expand
2Event LoopWhat is the difference between setTimeout(fn, 0), setImmediate, queueMicrotask, and process.nextTick in Node.js?
Click row to expand
3Event LoopWhat are Web Workers? How do they communicate with the main thread, and what are their limitations?
Click row to expand
4Closures & ScopeWhat is a closure? Explain the classic loop closure bug and its solutions.
Click row to expand
5Closures & ScopeExplain the temporal dead zone (TDZ) for let and const. How does hoisting differ for var, let, const, and function declarations?
Click row to expand
6Closures & ScopeWhat is the module pattern? Compare CommonJS, AMD, UMD, and ES Modules. What are the key differences?
Click row to expand
7Closures & ScopeExplain prototype chain and prototypal inheritance. How does Object.create differ from the class syntax?
Click row to expand
8Async PatternsHow does async/await work internally? What is it desugared to? What are the error-handling pitfalls?
Click row to expand
9Async PatternsWhat are the differences between Promise.all, Promise.allSettled, Promise.race, and Promise.any?
Click row to expand
10Async PatternsExplain generators and iterators in JavaScript. How are they used to implement async flow control and lazy sequences?
Click row to expand
11ES6+ FeaturesExplain Proxy and Reflect in JavaScript. What are practical use cases?
Click row to expand
12ES6+ FeaturesWhat are WeakMap and WeakSet? How do they differ from Map and Set, and what problems do they solve?
Click row to expand
13ES6+ FeaturesWhat is the difference between == and ===? Explain abstract equality coercion rules for key type pairs.
Click row to expand
14Performance & MemoryWhat causes memory leaks in browser JavaScript? How do you detect and fix them?
Click row to expand
15Performance & MemoryExplain JavaScript engine optimizations: hidden classes, inline caching, and deoptimization. How should you write optimizable code?
Click row to expand
16Performance & MemoryWhat is throttling vs debouncing? When should you use each? Implement both from scratch.
Click row to expand
17ES6+ FeaturesWhat is the difference between shallow and deep cloning in JavaScript? What are the tradeoffs of structuredClone, JSON.parse/stringify, and spread operator?
Click row to expand
18PatternsExplain the Observer pattern and how it relates to EventEmitter, RxJS Observables, and the DOM event system.
Click row to expand
19PatternsWhat is memoization? How do you implement it for single and multiple arguments? What are the tradeoffs?
Click row to expand
20Performance & MemoryWhat is CORS? Explain preflight requests, the same-origin policy, and how to configure CORS correctly on the server.
Click row to expand
21SecurityWhat is XSS (Cross-Site Scripting)? What are the types and how do you prevent them in JavaScript applications?
Click row to expand
22SecurityWhat is the difference between sessionStorage, localStorage, and cookies? When would you use each for auth?
Click row to expand
23PatternsWhat is functional programming in JavaScript? Explain pure functions, immutability, currying, and function composition.
Click row to expand
24ES6+ FeaturesExplain Symbol in JavaScript. What are the well-known symbols and how are they used?
Click row to expand
25PatternsWhat is the difference between imperative and declarative programming? Provide JavaScript examples of common transformation from imperative to declarative.
Click row to expand
26Event LoopHow does requestAnimationFrame work? When should you use it instead of setTimeout for animations?
Click row to expand
27ES6+ FeaturesWhat are tagged template literals? How are they used for safe SQL queries, styled-components, and internationalization?
Click row to expand
28Async PatternsWhat is the AbortController API? How does it enable cancellation for fetch requests and async operations?
Click row to expand
29PatternsExplain the difference between call, apply, and bind. How does 'this' binding work in different contexts?
Click row to expand
30SecurityWhat is CSRF (Cross-Site Request Forgery)? How do SameSite cookies and CSRF tokens prevent it?
Click row to expand
31ES6+ FeaturesWhat are Iterators and the Iterable protocol? How can you create a custom iterable data structure?
Click row to expand
32PatternsWhat is the difference between deep equality checking and reference equality in JavaScript? How do you implement structural equality?
Click row to expand
33ES6+ FeaturesExplain async generators and async iterators. What problem do they solve for streaming data?
Click row to expand
34Performance & MemoryWhat is tree shaking? How does it work, and what code patterns prevent it?
Click row to expand
35PatternsWhat is the difference between composition and inheritance in JavaScript? Why does the composition over inheritance principle matter?
Click row to expand
36ES6+ FeaturesWhat is optional chaining (?.) and nullish coalescing (??)? How do they differ from || for falsy checks?
Click row to expand
37Performance & MemoryWhat is the difference between synchronous and asynchronous module loading? How does dynamic import() work?
Click row to expand
38PatternsExplain the Repository pattern and how to implement it in JavaScript with dependency injection.
Click row to expand
39ES6+ FeaturesWhat is destructuring? Explain default values, renaming, nested destructuring, and rest patterns.
Click row to expand
40PatternsWhat are the core principles of clean API design in JavaScript? How do you design backward-compatible APIs?
Click row to expand
41ES6+ FeaturesExplain the Temporal API (TC39 Stage 3). How does it improve on the Date object?
Click row to expand
42Performance & MemoryWhat is the critical rendering path? How do JavaScript execution and render-blocking scripts affect page performance?
Click row to expand
43PatternsWhat is the pub/sub pattern? How does it differ from the Observer pattern, and how do you implement a typed event bus?
Click row to expand
44SecurityWhat is Content Security Policy (CSP)? How do you implement a strict CSP while supporting a React SPA?
Click row to expand
45PatternsWhat is the Strategy pattern in JavaScript? How do you implement runtime algorithm selection without if/else chains?
Click row to expand
46ES6+ FeaturesWhat are the key changes in ES2022 and ES2023? Explain Array at(), Object.hasOwn, Error.cause, and top-level await.
Click row to expand
47Event LoopWhat is long task detection? How do you break up long JavaScript tasks to keep the UI responsive?
Click row to expand
48PatternsWhat is lazy loading? Explain patterns for lazy initialization of objects, modules, and UI components.
Click row to expand
49PatternsWhat is dependency injection in JavaScript? How do you implement a simple DI container without a framework?
Click row to expand
50Performance & MemoryWhat is the Intersection Observer API? What rendering performance problems does it solve compared to scroll event listeners?
Click row to expand