JavaScript Interview Questions and Answers for Frontend and Full Stack Roles

By the HiReXL Career Team

JavaScript interviews often go beyond syntax to test how the language really works — scope, closures, asynchronous behavior and the event loop. Here are the most common JavaScript interview questions for frontend and full stack roles, with clear answers.

Fundamentals

var vs. let vs. const?

var is function-scoped and hoisted with undefined. let and const are block-scoped; const cannot be reassigned (though objects it references can be modified).

What is hoisting?

Declarations are moved to the top of their scope during compilation. Function declarations are fully hoisted; let and const exist in a “temporal dead zone” until declared.

== vs. ===?

== compares after type coercion; === compares value and type. Prefer ===.

What are truthy and falsy values?

Falsy values are false, 0, -0, 0n, “”, null, undefined and NaN. Everything else is truthy.

Functions, scope and closures

What is a closure?

A function that remembers variables from its outer scope even after that scope has finished executing. Closures power data privacy, factories and callbacks.

How does “this” work?

It depends on how a function is called: the object before the dot for methods, undefined in strict-mode standalone functions, the new instance for constructors, and the enclosing scope for arrow functions. call, apply and bind set it explicitly.

Arrow functions vs. regular functions?

Arrow functions have lexical this, no arguments object and cannot be used as constructors.

Asynchronous JavaScript

What is the event loop?

JavaScript runs on a single thread. The event loop executes the call stack, then processes microtasks (promises), then macrotasks (timers, I/O). This is why promise callbacks run before setTimeout callbacks.

Callbacks vs. promises vs. async/await?

Callbacks can lead to nested “callback hell.” Promises represent future values with then/catch. async/await is syntax over promises that makes asynchronous code read like synchronous code.

What does Promise.all do?

Runs promises in parallel and resolves when all succeed, or rejects on the first failure. Promise.allSettled waits for all regardless of outcome.

Objects and prototypes

What is prototypal inheritance?

Objects inherit properties from other objects through the prototype chain. Classes in ES6 are syntax over prototypes.

How do you copy objects?

Spread syntax and Object.assign create shallow copies. structuredClone creates deep copies of most data.

What is destructuring?

Extracting values from arrays or objects into variables: const { name, email } = user;

ES6+ features to know

Template literals, default parameters, rest/spread, modules (import/export), classes, Map and Set, optional chaining (?.), nullish coalescing (??), and array methods such as map, filter, reduce, find and flatMap.

Browser and frontend questions

  • What is the DOM and how does event delegation work?
  • What is the difference between localStorage, sessionStorage and cookies?
  • How do you improve page performance? (Lazy loading, code splitting, caching, minimizing re-renders.)
  • What is CORS?
  • In React: state vs. props, useEffect dependencies, keys in lists and preventing unnecessary renders.

Common coding exercises

  1. Implement debounce and throttle
  2. Deep-clone an object
  3. Flatten a nested array
  4. Implement Promise.all
  5. Group an array of objects by a property
  6. Build a simple event emitter

Review patterns in coding interview questions and the full stack developer roadmap.

Frequently asked questions

What JavaScript topics are most important for interviews?

Closures, this, promises and async/await, the event loop, prototypes and array methods are the most frequently tested topics.

Should I learn TypeScript for interviews?

Many companies use TypeScript, so familiarity with types, interfaces and generics is a strong advantage for frontend and full stack roles.

Do JavaScript interviews include React questions?

Frontend roles frequently include React or another framework, covering components, state, hooks and performance.

Got the interview? Make sure your resume tells the same story.

Interviewers read your resume right before they talk to you. HiReXL aligns it with the job description’s keywords so your experience and your answers match. HiReXL is built by 4As Consulting, a cloud and DevOps consulting firm. Looking for your next role? Submit your resume for open positions with PanAmerica Inc.

See how HiReXL helps →