Javascript Interview Questions
46 curated javascript interview questions with detailed answers and examples.
← Browse all interview questionsUnderstand forced synchronous layout, the read-write interleaving that triggers it, and the batching and containment strategies that eliminate it.
Learn how to transform functions into reusable, smaller functions using currying and partial application.
Learn how to control function execution rates using debouncing and throttling for performance optimization.
Learn how event delegation lets you handle events efficiently by listening on a parent instead of multiple child elements.
Understand how JavaScript automatically frees memory using reachability and reference checks.
Learn how iterators define custom iteration behavior and how generators make writing them easier.
Learn what causes memory leaks in JavaScript and how to prevent them in web apps and Node.js.
Understand the difference between microtasks and macrotasks in the JavaScript event loop.
Understand the difference between shallow and deep copying, and how reference types affect data duplication.
Understand how WeakMap and WeakSet help with memory-safe key/value storage using weak references.
Learn how Web Workers enable multi-threaded behavior in JavaScript for heavy computations.
Learn how to limit concurrent async operations in JavaScript using async queues and promise batching.
Learn to build a robust retry mechanism for failed API calls, handling transient network errors gracefully.
Understand how JavaScript handles tasks, microtasks, and macrotasks and how to predict async execution order.
Avoid inconsistent state in JavaScript apps by managing promise resolution order in concurrent async operations.
Prevent multiple token refreshes when parallel API calls fail by sharing a single refresh promise.
Implement a robust deep-clone that handles Dates, RegExps, and circular references, and know the tradeoffs.
Use event delegation to reduce listeners, support dynamic elements, and improve performance with advanced patterns.
Diagnose memory growth, understand mark-and-sweep, and apply strategies to prevent leaks in web apps and Node services.
Build a lightweight lazy-loading system that defers image downloads until images approach the viewport.
Move CPU-heavy tasks off the main thread with Web Workers, error handling, transferable objects, and fallback strategies.
Understand the differences in scope, this binding, and syntax between arrow and traditional functions.
Learn how callback functions work and why they are essential for asynchronous programming in JavaScript.
Explore different ways to clone objects and arrays without mutating the original data.
Understand the primitive and non-primitive data types in JavaScript and how they differ.
Learn why strict equality (===) avoids unexpected type coercion in JavaScript.
Learn how JavaScript moves variable and function declarations to the top of their scope.
Learn how variable declarations differ in scope and behavior in modern JavaScript.
Understand how spread and rest operators simplify working with arrays, objects, and functions.
Master ES6 template literals for cleaner string concatenation and embedded expressions.
Learn which values evaluate to true or false in JavaScript conditionals.
Learn how async/await simplifies asynchronous JavaScript code built on top of Promises.
Learn how call, apply, and bind control the "this" context and pass arguments to functions dynamically.
Understand closures in JavaScript — how inner functions remember variables from their parent scope.
Learn how destructuring assignment simplifies extracting values from arrays and objects.
Understand how the JavaScript event loop handles asynchronous operations and manages concurrency.
Understand higher-order functions — functions that take or return other functions for composable code.
Learn how map, filter, and reduce work in JavaScript and when to use each for transforming arrays.
Understand how Promises handle asynchronous operations in JavaScript and replace callback hell.
Understand how JavaScript inheritance works using the prototype chain and __proto__ references.
Understand how the this keyword behaves in different contexts — global, function, arrow, and class scopes.
Learn how to create a custom debounce function that supports leading-edge, trailing-edge, or both firing modes.
Learn how memory leaks occur in single-page apps, how to diagnose them with Chrome DevTools, and how to fix common leak sources.
Implement efficient infinite scrolling using IntersectionObserver, batching, and virtualized rendering.
Build a high-performance resize handler using timestamp-based throttle and requestAnimationFrame to avoid layout thrashing.
Process large datasets without freezing the UI using setTimeout, requestIdleCallback, or Web Workers.