ES6 interview questions and answers for JavaScript developers

ES6 interview questions check whether you know what the 2015 edition of JavaScript (and the yearly editions after it) changed, and why: block-scoped let and const, arrow functions that borrow this, destructuring with defaults, rest and spread, classes, modules, iterators, generators, Map and Set, promises and Proxy. Expect short snippets where you predict the output, a request to rewrite older ES5 code in modern syntax, and senior questions about module loading and when a feature is the wrong tool. The best answers name the rule behind each feature instead of listing syntax.

By Published 10 min read

Why interviewers still say "ES6"

ES6 is shorthand for ECMAScript 2015, the release that turned JavaScript into the language most teams write today. Later editions arrive every year and add smaller pieces (async and await, optional chaining, nullish coalescing, class fields), and many interviewers fold those into the same "ES6 questions" label. Front-end, full-stack and Node.js rounds all use these questions as a quick filter: a candidate who cannot explain why let fixes the classic loop bug, or what this means inside an arrow function, usually struggles with the framework questions that follow. Broader language behavior, such as coercion and the event loop, lives on the JavaScript interview questions page.

  1. Rapid concept checkTen minutes of short questions: let versus var, arrow functions, spread versus rest, what a Symbol is for.
  2. Predict the outputA snippet with closures in a loop, destructuring defaults or a generator. You talk through it line by line before answering.
  3. Modernize this codeAn ES5 function with var self = this, string concatenation and manual argument copying. You rewrite it and explain each change.
  4. Design and trade-offsFor mid and senior roles: modules and bundling, Proxy-based reactivity, when a Map beats an object, and how you ship to older browsers.

ES6 fundamentals questions

First-round questions for freshers and anyone moving from ES5
QuestionWhat it testsWhat a strong answer shows
How do let, const and var differ?Scope rulesvar is function-scoped and hoisted with the value undefined. let and const are block-scoped and sit in a temporal dead zone until their declaration runs. const forbids reassignment of the binding, not mutation of the object it points to.
What is the temporal dead zone?Hoisting detailThe stretch between entering a block and the line that declares a let or const. The name is reserved, so reading it throws a ReferenceError instead of quietly returning undefined.
Why does a let loop counter fix the closure-in-a-loop bug?Per-iteration bindingA for loop with let creates a new binding for every iteration, so each callback captures its own value. With var there is one shared variable that ends at its final value.
How is this decided inside an arrow function?Lexical thisArrows have no own this, arguments or prototype. They use the this of the enclosing scope at creation time, so call, apply and bind cannot change it.
When should you not use an arrow function?JudgmentObject methods that need the object as this, prototype methods, constructors (arrows cannot be called with new) and DOM handlers that rely on this being the element.
What do template literals add besides interpolation?StringsMulti-line strings without escapes, expressions inside ${}, and tagged templates, where a function receives the raw string parts and values separately (useful for escaping or query builders).
Rest versus spread?Same syntax, two jobsRest collects remaining items into an array in parameters or destructuring. Spread expands an iterable or an object's own enumerable properties into a call, array or object literal.
Does object spread make a deep copy?Copy semanticsNo. It copies own enumerable properties one level deep; nested objects are still shared. structuredClone or a deliberate recursive copy is needed for depth.
When does a default parameter value apply?DefaultsOnly when the argument is undefined, whether missing or passed explicitly. Passing null keeps null.
What are shorthand properties and computed keys?Object literals{ name } means { name: name }, and { [key]: value } uses an expression as the property name, which is handy for reducers and dynamic maps.
First-round questions for freshers and anyone moving from ES5. Scroll sideways on a small screen.
// let gets a fresh binding per loop iteration; var shares one.
const viaVar = [];
for (var i = 0; i < 3; i++) viaVar.push(() => i);
const viaLet = [];
for (let j = 0; j < 3; j++) viaLet.push(() => j);
console.log(viaVar.map((f) => f()), viaLet.map((f) => f()));

// Temporal dead zone: the binding exists but cannot be read yet.
try {
  console.log(total);
  let total = 1;
} catch (e) {
  console.log(e.constructor.name);
}

// An arrow function takes `this` from the method that created it.
const counter = {
  count: 0,
  makeTick() { return () => ++this.count; },
};
const tick = counter.makeTick();
console.log(tick(), tick());
Three classic predict-the-output checks. Node.js prints: [ 3, 3, 3 ] [ 0, 1, 2 ], then ReferenceError, then 1 2.

Intermediate ES6 questions

  • Are ES6 classes just syntax over prototypes? Mostly. Methods still live on the prototype and instances still link to it. But classes add real differences: the body runs in strict mode, class declarations are not usable before their line (they sit in a TDZ like let), and calling a class without new throws.
  • Why must a subclass call super() before using this? In a derived class the parent constructor creates the object. Until super() returns there is no this to read or write, so touching it first throws a ReferenceError.
  • What are static methods for? Helpers that belong to the class rather than an instance, such as factory functions (User.fromJSON). They are inherited by subclasses through the constructor chain.
  • How do ES modules differ from CommonJS? ES modules use static import and export that tools can analyze before running anything, which enables tree shaking. Imports are live read-only bindings, not copies. CommonJS require runs at call time and returns whatever module.exports holds then.
  • Named export or default export? Named exports keep the same name across the codebase and are easier to search and refactor. A default export lets each importer pick a name, which some teams avoid for that reason.
  • What makes an object iterable? A method under the key Symbol.iterator that returns an iterator: an object with next() returning { value, done }. Arrays, strings, Maps and Sets have one built in, which is why for...of and spread work on them.
  • What is a generator and why use one? A function* that pauses at each yield and resumes when next() is called. It is the shortest way to write an iterator, and it suits lazy sequences that would be too large to build as an array.
  • What is a Symbol for? A unique, non-string property key. It avoids name clashes on shared objects and powers built-in protocols such as Symbol.iterator. Symbol keys are skipped by for...in and JSON.stringify.
  • Map versus a plain object? A Map accepts any key type, keeps insertion order, has a size property and no inherited keys to trip over. Plain objects suit fixed, string-keyed records that need JSON.
  • When would you pick a WeakMap? To attach data to objects you do not own without keeping them alive: caches keyed by DOM nodes or request objects. Entries disappear when the key object is garbage-collected, and the map cannot be iterated.
  • How do you remove duplicates from an array in one line? [...new Set(items)]. A Set compares with SameValueZero, so NaN deduplicates too, while two different objects with the same contents do not.
// A class that is iterable through a generator.
class Range {
  constructor(start, end, step = 1) {
    Object.assign(this, { start, end, step });
  }
  *[Symbol.iterator]() {
    for (let n = this.start; n < this.end; n += this.step) yield n;
  }
}

const [first, , third = "none", ...rest] = new Range(0, 10, 2);
console.log(first, third, rest);

// Defaults apply only when the value is undefined, not null.
const connect = ({ host = "localhost", port = 5432 } = {}) => `${host}:${port}`;
console.log(connect(), connect({ port: null }), connect({ host: undefined }));

console.log([...new Set([3, 1, 3, 2, 1])], Math.max(...new Range(1, 4)));
Iterators, destructuring and defaults together. Output: 0 4 [ 6, 8 ], then localhost:5432 localhost:null localhost:5432, then [ 3, 1, 2 ] 3.

Interviewers like this snippet because it rewards reading the rules aloud. Array destructuring pulls values through the iterator, so the generator runs; the hole skips the second value; third receives 4, so its default is ignored; and the rest element gathers what is left. The = {} after the parameter pattern is what makes connect() with no argument safe.

Promises and async questions from the ES6 era

Asynchronous features, from ES2015 promises to async and await
QuestionWhat it testsWhat a strong answer shows
What states can a Promise be in?BasicsPending, then settled as fulfilled or rejected, once. Later resolve or reject calls are ignored.
Why does returning a value inside .then matter?ChainingThe next then receives it. Forgetting to return an inner promise breaks the chain, so later steps run before the work finishes.
Promise.all versus Promise.allSettled?Combinatorsall rejects as soon as one input rejects. allSettled waits for every input and reports each outcome, which suits batch jobs where partial success is fine.
Promise.race versus Promise.any?Combinatorsrace settles with the first input to settle, success or failure; it is the usual timeout pattern. any resolves with the first success and rejects only if all fail.
What does async/await change, and what does it not?Syntax over promisesIt makes promise code read top to bottom and lets try/catch handle rejections. It does not make work parallel: two awaits in a row run one after the other unless you start both first.
What happens to an unhandled rejection?Error handlingBrowsers log it, and recent Node.js versions end the process by default. Every chain needs a catch or a try/catch around its await.
Asynchronous features, from ES2015 promises to async and await. Scroll sideways on a small screen.

Senior ES6 and scenario questions

  • How does Proxy work, and where have you seen it used? A Proxy wraps an object and intercepts operations through traps such as get, set and has. Reactivity systems in some UI frameworks, validation layers and test doubles are common uses. Reflect provides the default behavior for each trap so you only change what you mean to.
  • What does tree shaking need from your code? Static ES module imports and exports, and modules without side effects at the top level. A barrel file that runs setup code on import, or a CommonJS dependency, can keep unused code in the bundle.
  • How do you ship modern syntax to older browsers? A transpiler such as Babel or a bundler's target setting rewrites syntax, while polyfills supply missing built-ins like Promise or Array.prototype.includes. They solve different problems, and teams pick targets from their own browser data.
  • How would you migrate a large ES5 codebase? In small steps behind tests: switch var to const and let with a linter rule, replace self = this with arrows only where this is lexical, convert modules file by file, and keep behavior the same in each pull request.
  • Is `const` an immutability guarantee? No. It locks the binding. Object.freeze makes one level read-only; real immutability needs discipline or a library.
  • What are private class fields and how do they differ from a WeakMap pattern? #name fields (a later edition, not 2015) are enforced by the language and invisible outside the class body. Before them, teams stored private state in a module-level WeakMap keyed by the instance.
  • Where can spread hurt performance? Spreading inside a loop or reducer copies the whole array or object each time, turning a linear pass into quadratic work on large inputs. Mutating a local accumulator is fine when nothing else sees it.
  • Why can a circular import give you undefined? With ES modules the binding exists but may not be initialized yet when the other module first reads it, which can throw a TDZ error; with CommonJS you get a partially filled exports object. The fix is usually to move the shared piece into a third module.
// A Proxy that rejects writes of the wrong type, using Reflect for the default.
function typed(target, types) {
  return new Proxy(target, {
    set(obj, key, value, receiver) {
      if (key in types && typeof value !== types[key]) {
        throw new TypeError(`${String(key)} must be a ${types[key]}`);
      }
      return Reflect.set(obj, key, value, receiver);
    },
  });
}

const user = typed({ name: "Ada", age: 36 }, { name: "string", age: "number" });
user.age = 37;
try {
  user.age = "thirty-eight";
} catch (e) {
  console.log(e.message);
}
console.log(JSON.stringify(user));
Proxy plus Reflect as a small validation layer. Output: age must be a number, then {"name":"Ada","age":37}.

Fictional example

Answering "Modernize this ES5 function"
Interviewer
This function uses var self = this, builds a URL with plus signs, copies arguments with slice, and loops over results with a for loop and an index. How would you rewrite it?
Candidate
I would keep the behavior identical and change one idea at a time. The callback becomes an arrow, so self goes away because the arrow reads this from the method. The URL becomes a template literal, which removes the quoting mistakes. The arguments copy becomes a rest parameter, which gives me a real array. The loop becomes for...of, since I never use the index. Variables become const unless they are reassigned. Before shipping I would check one thing: if this function is passed somewhere as a callback that sets its own this, the arrow would change behavior, so I would search the call sites first.

A one-week ES6 practice plan

  • Day 1: scope. Write the var and let loop, trigger a TDZ error on purpose, and explain both out loud in under a minute.
  • Day 2: functions. Rewrite five callbacks as arrows and find the one where that breaks; practice default and rest parameters.
  • Day 3: destructuring and spread. Swap two variables, pull nested fields with defaults, and show where object spread shares nested data.
  • Day 4: classes and modules. Build a small class hierarchy with super and a static factory; split it into ES modules with named exports.
  • Day 5: iteration. Make a custom iterable with a generator, then use it with for...of, spread and destructuring.
  • Day 6: async. Rewrite a promise chain with async and await, then run two requests in parallel and add a timeout with Promise.race.
  • Day 7: a mock round with predict-the-output snippets, spoken explanations only, no running the code until you have committed to an answer.

ES6 knowledge rarely stands alone in a loop. Server-side rounds continue in Express.js interview questions, typed codebases in TypeScript interview questions, and runtime behavior in Node.js interview questions.

Output questions punish you for answering before you have stated the rule, and that habit is easiest to see in a recording of yourself. Natively, an AI interview assistant for Mac and Windows, transcribes a practice session on your computer so you can check whether you said "fresh binding per iteration" or just guessed the numbers. During practice it can read a snippet from a screenshot and talk through what it prints, help with a modernize-this-code exercise, and use the résumé and job description you add (with Pro or the free trial) to aim questions at the stack you are applying for. Transcripts and notes stay available to review afterward.

Questions people ask

What ES6 questions are asked in interviews?

let, const and var, the temporal dead zone, arrow functions and this, destructuring with defaults, rest and spread, classes and super, ES modules, iterators and generators, Map and Set, promises and, for senior roles, Proxy and tree shaking.

What is the difference between ES6 and JavaScript?

JavaScript is the language; ES6 is ECMAScript 2015, the edition of its standard that added classes, modules, arrow functions, let and const, promises and more. Interviewers often use "ES6" loosely for all modern JavaScript features.

How do I answer ES6 output questions?

Name the rule first, for example that let creates a new binding per loop iteration or that a default applies only to undefined, then walk the snippet line by line and give the output.

Are ES6 questions asked for experienced developers?

Yes, but at more depth: module loading and circular imports, Proxy and Reflect, the cost of spread in loops, transpiling and polyfills, and how to modernize a legacy codebase safely.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP