/writing/recruiting & ats/questions-for-javascript-interview
§ Hiring Tips·24 min read·September 28, 2026

35 JavaScript Interview Questions and Answers to Know

O
Olibr TeamHiring Tips
§ Contents
35 JavaScript Interview Questions and Answers to Know1. JavaScript fundamentals and core conceptsWhat are the different data types in JavaScript?What is the difference between == and === operators?What is hoisting in JavaScript?What is the difference between null and undefined?Why does typeof null return object?2. Variables, scope, and hoistingWhat is the difference between var, let, and const?What is the Temporal Dead Zone in JavaScript?What is the difference between global, function, and block scope?What is lexical scope in JavaScript?3. Functions, closures, and higher-order functionsWhat is a closure and why is it useful?What is an Immediately Invoked Function Expression?What are higher-order functions in JavaScript?What is currying in JavaScript?What is the difference between function declarations and expressions?4. The this keyword, call, apply, and bindHow does the this keyword work in JavaScript?What is the difference between call, apply, and bind?How do arrow functions handle this differently?5. Objects, prototypes, and classesWhat is the prototype chain in JavaScript?How do ES6 classes differ from constructor functions?What is the difference between passed by value and passed by reference?What is the difference between shallow and deep cloning?6. Asynchronous JavaScript and the event loopWhat is the event loop in JavaScript?What are Promises and how do they work?What is the difference between async/await and Promises?What is callback hell and how do you avoid it?7. Arrays, objects, and modern data structuresWhat is the difference between map, filter, and reduce?What is destructuring in JavaScript?What is the difference between spread and rest operators?What is the difference between Map, Set, and plain objects?What is the difference between nullish coalescing and logical OR?8. DOM, performance, and practical coding questionsWhat is the DOM and how do you manipulate it?What is the difference between debouncing and throttling?What is memoization and when should you use it?What is the difference between synchronous and asynchronous code?What is the difference between client-side and server-side JavaScript?Preparing confidently for your JavaScript interview
35 JavaScript Interview Questions and Answers to Know

35 JavaScript Interview Questions and Answers to Know

If you're hiring for a JavaScript role, you already know that a resume full of frameworks and buzzwords tells you almost nothing about how someone actually codes. Whether you're a technical recruiter, a staffing agency screening candidates for a client, or a hiring manager running the first round yourself, you need a reliable set of questions for javascript interview rounds that actually separate strong developers from candidates who just memorized syntax. This list gives you exactly that: real questions you can use in phone screens, technical rounds, or panel interviews.

Below you'll find 35 javascript interview questions covering everything from closures and hoisting to async/await, prototypal inheritance, and the event loop, each paired with a clear, correct answer so you know what a good response sounds like even if you're not a JavaScript engineer yourself. These aren't generic trivia questions pulled from a forum; they're organized by difficulty so you can match them to junior, mid-level, or senior openings.

As you work through this list, think about how you'll run these technical interviews remotely at scale. If you're screening dozens of candidates a week, manually asking the same interview questions javascript developers face gets slow fast, which is where one-click interview invites with AI scoring and structured scorecards save real hours. Let's get into the questions.

1. JavaScript fundamentals and core concepts

Every strong JavaScript interview starts here, before frameworks, before libraries, before anything trendy. If a candidate can't explain the core language mechanics cleanly, no amount of React or Node experience will save them on a hard bug six months into the job. Use these five questions as your opening filter in any set of javascript interview questions, whether you're screening a junior developer with entry-level JavaScript questions or double-checking a senior hire's fundamentals haven't gone rusty.

What are the different data types in JavaScript?

Ask this early because it reveals whether a candidate actually understands JavaScript's type system or just codes by trial and error. JavaScript has seven primitive types and one reference type, and a good answer distinguishes between them without prompting.

Category Types Example
Primitive String, Number, Boolean, Undefined, Null, Symbol, BigInt "hello", 42, true
Reference Object (includes Array, Function, Date) {}, [1,2,3], function(){}

Strong candidates will also mention that primitives are compared by value while objects are compared by reference, which sets up several later questions on this list.

What is the difference between == and === operators?

Here you're testing whether the candidate understands type coercion, one of JavaScript's most infamous quirks. The == operator compares values after converting both sides to the same type, so "5" == 5 returns true. The === operator, called strict equality, compares both value and type without conversion, so "5" === 5 returns false. Listen for candidates who default to explaining that === is the safer choice in production code, since that shows practical judgment, not just textbook recall.

What is hoisting in JavaScript?

Hoisting trips up even experienced developers, which makes it one of the most revealing interview questions on javascript you can ask. JavaScript moves variable and function declarations to the top of their scope during compilation, before the code actually runs. Variables declared with var are hoisted and initialized as undefined, while let and const are hoisted but not initialized, leaving them in an inaccessible state until the line where they're defined. Function declarations are hoisted completely, body included, which is why you can call a function before its definition appears in the file.

If a candidate can't explain why calling a let variable before its declaration throws an error, they don't yet understand how JavaScript actually executes code.

What is the difference between null and undefined?

This question separates candidates who've written production code from those who've only completed tutorials. undefined means a variable has been declared but never assigned a value, and it's also what JavaScript returns automatically for missing function arguments or non-existent object properties. null is an intentional assignment representing "no value," set deliberately by the developer. Good candidates will point out that null == undefined is true because of coercion, but null === undefined is false, tying this answer back to the equality question above.

Why does typeof null return object?

This one catches almost everyone off guard, and that's exactly why it belongs on your list. Running typeof null in any JavaScript environment returns "object", which is technically a bug baked into the language since its earliest versions. The original implementation represented values using a type tag, and objects had a type tag of 0; null was represented as the null pointer, which also happened to be 0, so it got misclassified. Fixing it now would break too much existing code across the web, so it remains a documented quirk rather than an error. You're not looking for candidates to know this trivia cold, you're looking for how they react to being surprised, since real debugging sessions are full of exactly these kinds of edge cases. A candidate who says "I don't know, but here's how I'd check the documentation" is often a better hire than one who bluffs an answer.

2. Variables, scope, and hoisting

Once a candidate has the fundamentals down, move into how JavaScript actually manages memory and access across a program. This is where many self-taught developers stumble, because variable scope rules changed significantly with ES6, and plenty of candidates learned JavaScript from outdated tutorials that never mention the difference. These four questions work well as a mid-section filter in any list of JavaScript questions at the intermediate level, especially for roles touching legacy codebases still full of var.

What is the difference between var, let, and const?

Ask this to check whether a candidate writes modern JavaScript or is still stuck in 2014 habits. var is function-scoped, can be redeclared, and gets hoisted with a default value of undefined. let is block-scoped, can be reassigned but not redeclared in the same scope, and stays in the temporal dead zone until its declaration line runs. const behaves like let but cannot be reassigned after initialization, though objects and arrays declared with const can still have their contents mutated.

Keyword Scope Reassignable Redeclarable Hoisting behavior
var Function Yes Yes Initialized as undefined
let Block Yes No Uninitialized (TDZ)
const Block No No Uninitialized (TDZ)

Strong candidates default to const, reach for let only when reassignment is genuinely needed, and can explain why they'd avoid var in new code.

What is the Temporal Dead Zone in JavaScript?

Building on hoisting, this question tests whether the candidate understands the mechanics behind those let and const errors they've probably hit dozens of times. The Temporal Dead Zone, or TDZ, is the period between when a scope starts and when a let or const variable is actually declared within it. Accessing the variable during that window throws a ReferenceError rather than returning undefined, which is exactly why let and const feel stricter than var. Candidates who can explain the TDZ usually understand hoisting at a deeper level than those who only memorized the var versus let comparison.

What is the difference between global, function, and block scope?

Questions on scope reveal whether a candidate can predict variable visibility without running the code first. Global scope means a variable is accessible anywhere in the program, which is generally something you want to minimize in real applications. Function scope means a variable declared with var inside a function is only accessible within that function. Block scope, introduced with let and const, restricts access to whatever {} block the variable was declared in, including if statements and loops. Candidates who've worked on larger codebases will usually volunteer that leaning too heavily on global scope creates naming collisions and hard-to-trace bugs.

What is lexical scope in JavaScript?

This question digs one level deeper into how JavaScript resolves variable names. Lexical scope means a function's access to variables is determined by where it's physically written in the code, not by where or how it's called. A nested function can always access variables from its enclosing functions, because that relationship is fixed at the time the code is written. Understanding lexical scope is a prerequisite for the closures question coming next, so if a candidate stumbles here, flag it before moving on.

3. Functions, closures, and higher-order functions

Functions are where JavaScript stops looking like other languages and starts showing its personality. This section of javascript interview questions tests whether a candidate understands functions as first-class citizens, meaning they can be passed around, returned, and wrapped just like any other value. Candidates who've only worked in rigid, class-heavy languages often stumble here, so use these five questions to gauge how comfortable someone is with JavaScript's more flexible, functional side.

Three nested wooden boxes with a small brass key inside the smallest one.

What is a closure and why is it useful?

Closures come up constantly in real code, so this is one of the most practical interview questions for javascript you can ask. A closure happens when a function retains access to variables from its enclosing scope even after that outer function has finished running. This is why a counter function can remember its count between calls without relying on a global variable. Good candidates will mention practical uses like data privacy, memoization, and callback functions that need to remember state.

A candidate who can build a working counter using closures, without looking it up, understands JavaScript scope at a level tutorials rarely teach.

What is an Immediately Invoked Function Expression?

Developed before ES6 modules existed, an Immediately Invoked Function Expression, or IIFE, is a function defined and executed in the same statement, typically written as (function() { ... })(). Its main job was creating a private scope to avoid polluting the global namespace, which mattered a lot before let, const, and modules gave developers cleaner options. A candidate who's only worked with modern bundlers might not reach for an IIFE often, but they should still recognize the pattern when they see it in older code.

What are higher-order functions in JavaScript?

Higher-order functions either accept another function as an argument, return a function, or both. Common examples include map, filter, and reduce, along with custom wrapper functions used for logging or timing. Recognizing this pattern matters because functional programming techniques are everywhere in modern JavaScript codebases, especially in React and Node projects. If a candidate can explain why array.map(callback) counts as a higher-order function, they understand the concept well enough for production work.

What is currying in JavaScript?

Currying transforms a function that takes multiple arguments into a sequence of functions that each take one argument, like turning add(a, b) into add(a)(b). It's a more advanced technique, so don't expect junior candidates to nail this without hesitation. Senior candidates, though, should be able to explain how currying enables function composition and reusable, partially-applied functions, particularly in libraries built around functional patterns.

What is the difference between function declarations and expressions?

Understanding this distinction ties directly back to the hoisting question earlier in this list. A function declaration, written as function greet() {}, is fully hoisted and callable before its line in the code. A function expression, written as const greet = function() {}, is only hoisted as a variable, so the assignment must run first or the code throws an error. Candidates who know this instinctively usually write more predictable code around load order.

4. The this keyword, call, apply, and bind

Few topics confuse junior developers faster than this, and few topics reveal senior-level understanding as clearly. Almost every list of interview js questions includes this topic because so many production bugs trace back to a misunderstood this binding inside a callback or event handler. Use these three questions to see whether a candidate actually reasons through binding rules or just guesses based on pattern matching.

How does the this keyword work in JavaScript?

Unlike variables, which follow lexical scope, this is determined by how a function is called, not where it's written. Calling a method as object.method() binds this to object. Calling a standalone function in non-strict mode binds this to the global object, while strict mode leaves it undefined. Using new with a constructor binds this to the newly created instance. Candidates who can walk through these four call patterns without hesitating usually have real debugging experience, since misassigned this is one of the most common runtime bugs in callback-heavy code.

If a candidate can't explain why this breaks inside a regular function passed as a callback, they'll struggle the first time a production bug depends on it.

What is the difference between call, apply, and bind?

All three methods let you explicitly set what this refers to inside a function, but they behave differently enough that mixing them up causes real bugs. Ask the candidate to explain each one, then watch whether they can articulate the argument-passing difference between call and apply without looking it up.

Method Invokes immediately? Arguments format Common use case
call Yes Comma-separated list Borrowing a method from another object
apply Yes Array Passing a variable number of arguments
bind No Comma-separated list Creating a new function with fixed this for later use

A strong candidate will mention that bind returns a new function rather than executing it, which makes it useful for event handlers and delayed callbacks where you need to lock in this ahead of time.

How do arrow functions handle this differently?

Building on the previous two answers, arrow functions solve the this confusion by not having their own this at all. Instead, they inherit this from the enclosing lexical scope at the time they're defined, which is exactly why arrow functions became so popular for callbacks inside class methods and array operations. This also means call, apply, and bind can't change an arrow function's this, since there's no binding to override. Candidates who understand this distinction will usually explain that arrow functions are a poor choice for object methods, since you actually want this to refer to the object calling the method, not whatever scope surrounded the function's definition. That single tradeoff, convenience for callbacks versus unpredictability for methods, is a great signal of whether someone has shipped real JavaScript or only studied it in isolation.

5. Objects, prototypes, and classes

Objects sit at the center of nearly everything in JavaScript, so this section separates candidates who memorized ES6 syntax from those who understand what's actually happening underneath it. These four questions belong in any serious set of interview questions on javascript, especially for roles building anything beyond simple CRUD screens, and they pair well with deeper questions for experienced JavaScript developers, since prototype confusion causes real bugs in inheritance-heavy codebases.

What is the prototype chain in JavaScript?

Every JavaScript object has an internal link to another object called its prototype, and when you try to access a property that doesn't exist directly on an object, JavaScript walks up this chain looking for it. This continues until it reaches Object.prototype, where the chain ends in null. It's why arrays can call .map() or .filter() without you defining those methods yourself, since they're inherited from Array.prototype. A candidate who can explain that JavaScript uses prototypal inheritance rather than classical inheritance, and can describe how Object.create() sets up that link manually, understands the language at a deeper level than someone who only knows the class keyword.

Prototypal inheritance is the mechanism, classes are just a friendlier syntax layered on top of it.

How do ES6 classes differ from constructor functions?

Before ES6, developers created reusable object blueprints using constructor functions combined with manual prototype assignments, something like function Person(name) { this.name = name; } followed by Person.prototype.greet = function() {...}. The class keyword introduced in ES6 doesn't replace this system, it just wraps it in cleaner syntax; under the hood, classes still use prototypes. Ask candidates to point out that classes aren't hoisted the same way function declarations are, and that class bodies always run in strict mode automatically, two details that trip up people who've only ever used class without understanding what it compiles down to.

What is the difference between passed by value and passed by reference?

This question exposes a common source of confusing bugs, and it's one of the more practical javascript questions for interview rounds because it shows up constantly in real debugging sessions. Primitive values like strings, numbers, and booleans are copied and passed by value, meaning changes inside a function don't affect the original variable. Objects and arrays are passed by reference, so modifying a property inside a function changes the original object outside it too, since both variables point to the same location in memory. Candidates who've been burned by accidentally mutating a shared object usually explain this one with real conviction rather than textbook phrasing.

What is the difference between shallow and deep cloning?

Building directly on the previous answer, cloning questions test whether a candidate knows how to actually avoid reference bugs in practice. A shallow clone, created with something like Object.assign({}, obj) or the spread operator {...obj}, copies only the top-level properties, so nested objects inside it still point back to the original. A deep clone copies every nested level, fully separating the new object from the original, commonly done with structuredClone() in modern environments or a recursive helper function in older code. Strong candidates will mention that JSON.parse(JSON.stringify(obj)) was a common workaround for years, but it breaks on functions, undefined values, and dates, which is exactly why structuredClone() became the safer standard.

6. Asynchronous JavaScript and the event loop

Async questions expose whether a candidate understands JavaScript's single-threaded nature or has just memorized async/await syntax without knowing what happens underneath. This section belongs near the end of any serious set of interview questions javascript teams use for mid-level and senior hiring, alongside advanced JavaScript interview questions, since asynchronous bugs, race conditions, and unhandled promise rejections cause some of the most painful production incidents you'll see in a JavaScript codebase.

Five-step process diagram showing how JavaScript's call stack, web APIs, callback queue, and event loop work together.

What is the event loop in JavaScript?

JavaScript runs on a single thread, meaning it can only execute one piece of code at a time, yet it handles network requests, timers, and user input without freezing the page. The event loop makes this possible by continuously checking whether the call stack is empty, and if it is, pulling the next task from a queue and pushing it onto the stack to run. Background work like setTimeout callbacks, fetch responses, and DOM events wait in these queues until the main thread is free. Candidates who understand the event loop can explain why console.log statements sometimes print in an order that looks wrong at first glance, which is a great real-world check on whether this knowledge is theoretical or practical.

If a candidate can't explain why a setTimeout(fn, 0) still runs after synchronous code finishes, they don't yet understand how JavaScript actually schedules work.

What are Promises and how do they work?

A Promise represents a value that isn't available yet but will be at some point, either successfully (resolved) or with an error (rejected). Promises have three states: pending, fulfilled, and rejected, and once settled, that state never changes again. Chaining methods like .then(), .catch(), and .finally() lets developers handle success and failure without nesting callbacks inside each other. Ask candidates to walk through what happens if you forget a .catch() on a rejected promise, since unhandled rejections are a common source of silent failures in production apps.

What is the difference between async/await and Promises?

Async/await is syntactic sugar built directly on top of Promises, not a separate feature competing with them. Marking a function async means it always returns a Promise, and using await inside it pauses execution at that line until the Promise resolves, without blocking the rest of the application. This makes asynchronous code read like synchronous code, which is a huge readability win over long .then() chains, especially once you're handling multiple sequential async calls. Strong candidates will mention that try/catch blocks replace .catch() for error handling with async/await, and that both approaches ultimately run on the same underlying Promise mechanism.

What is callback hell and how do you avoid it?

Callback hell describes deeply nested callback functions, often shaped like a sideways pyramid, that happen when each async operation depends on the previous one completing first. It makes code hard to read, harder to debug, and nearly impossible to handle errors consistently across every nested level. Promises solved much of this by flattening the structure through chaining, and async/await solved it further by removing the nesting almost entirely. Candidates who've maintained legacy Node code will usually have a war story here, which tells you they've actually lived through the problem rather than just read about it.

7. Arrays, objects, and modern data structures

Modern JavaScript code leans heavily on a handful of array and object methods that didn't exist a decade ago, and candidates who learned the language recently often use them fluently without understanding the tradeoffs underneath. This section of javascript interview questions checks whether someone reaches for the right tool intentionally or just copies patterns they've seen in tutorials. Ask these five questions when you want to see how a candidate handles data transformation, the daily bread-and-butter work of most JavaScript roles.

Hand sorting labeled index cards from larger trays into a smaller tray.

What is the difference between map, filter, and reduce?

These three array methods get used constantly, so a candidate should explain each one without hesitating. map() transforms every item in an array and returns a new array of the same length. filter() returns a new array containing only the items that pass a test condition, so the result can be shorter than the original. reduce() collapses an entire array down into a single value, whether that's a sum, an object, or even another array, by running an accumulator function across every element. Candidates who default to reduce() for everything, even simple filtering, often haven't thought through readability tradeoffs for the next developer touching their code.

What is destructuring in JavaScript?

Destructuring lets you unpack values from arrays or properties from objects into individual variables in a single line, like const { name, age } = person instead of accessing each property separately. Array destructuring works positionally, so const [first, second] = list grabs items by index rather than by name. Good candidates will mention default values and renaming, such as const { name: fullName = "Unknown" } = person, since real codebases lean on these shortcuts constantly in function parameters and API responses.

What is the difference between spread and rest operators?

Both use the same ... syntax, which is exactly why this question trips people up. The spread operator expands an array or object into individual elements, useful for copying arrays, merging objects, or passing multiple arguments to a function. The rest operator does the opposite, collecting multiple remaining arguments or properties into a single array or object, most often seen in function parameters like function sum(...numbers).

Spread unpacks, rest packs. Candidates who mix those up haven't written enough real code with either.

What is the difference between Map, Set, and plain objects?

Map stores key-value pairs like a plain object, but keys can be any type, not just strings, and insertion order is guaranteed. Set stores unique values only, automatically discarding duplicates, which makes it ideal for deduplication tasks. Plain objects remain the default choice for most JavaScript work, but a candidate who reaches for Map when keys aren't strings, or Set when uniqueness matters, shows they understand modern data structures beyond the basics.

What is the difference between nullish coalescing and logical OR?

The || operator returns the right-hand value whenever the left side is falsy, which incorrectly catches 0, empty strings, and false as "missing" values. The ?? operator, nullish coalescing, only falls back when the left side is strictly null or undefined, making it the safer choice for default values involving numbers or booleans.

8. DOM, performance, and practical coding questions

Beyond language theory, a candidate needs to know how JavaScript actually touches the browser and behaves under real-world load. These final five questions round out any solid set of javascript interview questions by testing practical judgment rather than pure syntax recall, and they pair naturally with JavaScript coding challenges candidates solve live, which matters most for roles building actual user-facing products rather than backend scripts.

What is the DOM and how do you manipulate it?

The Document Object Model, or DOM, is the browser's in-memory representation of an HTML page as a tree of nodes, and JavaScript can read or modify that tree to change what the user sees without reloading the page. Common manipulation methods include document.querySelector() for finding elements, .textContent or .innerHTML for changing content, and .appendChild() for adding new nodes. A candidate should also mention that excessive DOM manipulation is slow, since each change can trigger a browser reflow or repaint, which is why frameworks like React introduced virtual DOM diffing to batch updates efficiently.

What is the difference between debouncing and throttling?

Both techniques control how often a function runs in response to rapid events like scrolling, resizing, or typing, but they solve slightly different problems. Debouncing delays execution until a pause in activity occurs, resetting the timer every time the event fires again, which works well for search-as-you-type inputs. Throttling guarantees a function runs at most once every set interval regardless of how often the event fires, which suits scroll or resize handlers where you still want regular updates.

Technique Behavior Common use case
Debounce Waits for a pause, then runs once Search input, form validation
Throttle Runs at fixed intervals during activity Scroll tracking, window resize

Debouncing waits for silence, throttling keeps a steady rhythm. A candidate who can't explain when each one causes bugs hasn't built anything performance-sensitive.

What is memoization and when should you use it?

Memoization caches the result of an expensive function call based on its input, so calling the same function again with the same arguments returns the stored result instead of recalculating it. This works best on pure functions, ones that always return the same output for the same input and produce no side effects, since caching an impure function's result would return stale or incorrect data. Candidates should recognize memoization as a closure-based pattern, tying back to the earlier closures question, and mention libraries like React's useMemo as a practical, everyday example.

What is the difference between synchronous and asynchronous code?

Synchronous code runs line by line, and each operation blocks the next one until it finishes. Asynchronous code lets long-running tasks, like network requests or file reads, happen in the background without freezing execution of everything else. This distinction connects directly back to the event loop discussion, and a strong candidate will explain why blocking operations on the main thread, like a massive synchronous loop, freeze the entire user interface.

What is the difference between client-side and server-side JavaScript?

Client-side JavaScript runs in the browser, handling DOM updates, form validation, and user interactions directly on the user's device. Server-side JavaScript, typically run through Node.js, handles database queries, authentication, and API logic on a remote server before sending results back to the browser, so back-end candidates deserve a round of Node.js interview questions too. Candidates applying for full-stack roles should explain this distinction clearly, since confusing the two environments often leads to security mistakes, like trusting client-side validation as the only line of defense.

Preparing confidently for your JavaScript interview

Running through these 35 javascript interview questions gives you a repeatable framework instead of a random grab bag of trivia. You now have questions that test fundamentals, scope, closures, async behavior, and practical coding judgment, organized so you can pick the right depth for a junior screen or a senior panel round. The goal was never to trip candidates up with obscure trivia, it was to give you a way to hear how someone actually thinks through real JavaScript problems under pressure.

Once you've settled on your question set, the next challenge is running these interviews efficiently across dozens of candidates without burning your whole week. That's exactly where a structured hiring platform pays off, especially one built around verified, pre-screened profiles instead of cold resumes. If you're hiring JavaScript talent right now, browse verified JavaScript developer profiles and start shortlisting developers who've already proven they can answer questions like these.

For engineers

Find work worth your time.

Live engineering roles across India and the US, matched to your stack. Build a profile recruiters actually discover.

Browse jobsHow it works

O
§ The author

Olibr Team

Reviewed by Raman Gupta, Founder, Olibr

Filed underHiring Tips
Reading time24 min · 4,793 words

PublishedSeptember 28, 2026

CategoryHiring Tips
Enjoyed this piece?Share it with someone who would find it useful.
§ Stay in the loop

Don’t miss the next one.

We publish essays on engineering, hiring, and building teams. Subscribe and we’ll send them when they land.

Unsubscribe anytime · one letter, never more