JavaScript Interview Questions and Answers
JavaScript interview questions for .NET developers — closures, the event loop, prototypes, this binding, promises and async/await, and var vs let vs const.
31Questions
10Topics
Basic to AdvancedDifficulty
Fresher to 5+ YrsExperience
- 01 What is the difference between debouncing and throttling? Debounce — wait until events stop for X ms, then fire once (search-as-you-type: run the query only after the user…
- 02 What are first-class functions and higher-order functions? First-class functions means functions are values — you can store them in variables, put them in arrays/objects, pass…
- 03 What is the difference between == and === in JavaScript? === (strict equality) compares value and type with no conversion. == (loose equality) coerces the operands to a common…
- 04 What is the difference between null and undefined in JavaScript? undefined means a variable has been declared but not assigned, or a property/return value doesn't exist — it's the…
- 05 What is a Promise, and how does it compare to callbacks and async/await? A Promise is an object representing a value that will be available later — it's pending, then fulfilled or rejected.…
- 06 What is hoisting in JavaScript? Hoisting is the engine processing declarations before executing code. var declarations are hoisted and initialised to…
- 07 What is the difference between map, filter and reduce? map transforms each element and returns a new array of the same length. filter keeps elements that pass a test and…
- 08 What is event bubbling and capturing in the DOM? When an event fires on an element, it propagates in three phases: capture (document → target, listeners with {capture:…
- 09 What is the difference between an arrow function and a regular function? Arrow functions have no this of their own — they inherit it from the enclosing scope (lexical this). They also have no…
- 10 What is prototypal inheritance in JavaScript? Every JavaScript object has an internal link to another object — its prototype. When you access a property that isn't…
- 11 What is the difference between the spread and rest operators? Both use .... Spread expands an iterable into individual elements — [...a, ...b], fn(...args), {...obj, extra: 1}.…
- 12 What is destructuring in JavaScript? Destructuring pulls values out of arrays or objects into variables in one statement: const { name, age } = user; or…
- 13 What are ES modules, and how do they differ from CommonJS? ES modules (import/export) are the standard JavaScript module system — statically analysable, so bundlers can…
- 14 What is the difference between debounce and throttle? Debounce — wait until events stop for N ms, then fire once. Good for a search box: run the query after the user pauses…
- 15 What is the difference between localStorage, sessionStorage and cookies? localStorage — key/value, ~5MB, persists until cleared, per origin, not sent to the server. sessionStorage — same but…
- 16 What is the DOM, and roughly how does the browser render a page? The DOM is an in-memory tree representation of the HTML that JavaScript can read and modify. Rendering roughly: parse…
- 17 How does fetch work, and how do you handle errors with it? fetch(url) returns a promise that resolves to a Response. The catch: it only rejects on a network failure — a 404 or…
- 18 What is the temporal dead zone? The temporal dead zone (TDZ) is the region from the start of a block until a let/const declaration is reached. The…
- 19 What is currying and partial application? Currying transforms a function of N arguments into N functions of one argument each: add(a)(b)(c). Partial application…
- 20 What is 'callback hell', and how do promises and async/await solve it? Callback hell (“the pyramid of doom”) is deeply nested callbacks — each async step nested inside the previous one's…
- 21 What is the difference between typeof and instanceof? typeof returns a string for the primitive type ("string", "number", "boolean", "undefined", "function", "object",…
- 22 What is memoization, and where is it useful in JavaScript? Memoization caches a function's result keyed by its arguments, so a repeated call with the same inputs returns the…
- 23 What is Cross-Site Scripting (XSS), and how do you prevent it? XSS is injecting attacker-controlled script into a page so it runs in other users' browsers — stealing cookies/tokens,…
- 24 Is JavaScript single-threaded or multi-threaded? JavaScript execution is single-threaded — one call stack, one thing at a time. Concurrency comes from the environment:…
- 25 What is the difference between slice and splice? slice(start, end) returns a shallow copy of a portion of the array and doesn't change the original. splice(start,…
- 26 What are optional chaining (?.) and nullish coalescing (??)? a?.b?.c short-circuits to undefined if any link is null/undefined, instead of throwing. a ?? b returns b only when a…
- 27 What are Set and Map in JavaScript, and when do you use them over objects and arrays? Set holds unique values — great for de-duplication ([...new Set(arr)]) and fast membership checks. Map is a key/value…
- 28 What is a closure in JavaScript? A closure is a function bundled with references to the variables from the scope where it was defined. Even after that…
- 29 How does the JavaScript event loop work? JavaScript runs on a single thread with a call stack. Async work (timers, I/O, promises) is handed to the host, and…
- 30 What is the difference between var, let and const? var is function-scoped, hoisted and initialised to undefined, and can be redeclared. let and const are block-scoped…
- 31 How is `this` determined in JavaScript? this is set by how a function is called, not where it's defined. Rules in priority order: new → the new object;…
No questions match those filters
Try removing a filter or .
About these JavaScript questions
Full-stack .NET roles almost always include a JavaScript round. The recurring themes are closures, the single-threaded event loop and the task/microtask queues, prototypal inheritance, how this is determined at call time, and the move from callbacks to promises to async/await.