ES6 interview questions.

ES6 (ES2015) and the versions after it changed how JavaScript is written, and interviews still ask about each feature: what it does, how it differs from the old way, and when it surprises people. These questions have you use classes, Map and Set, symbols, iterators, generators and modules in real code, with written answers to the concept questions below them.

3 of these questions have free answers; the rest are in Pro. Updated .

104

questions

Easy
38
Medium
44
Hard
22

What interviewers look for

  • You know how let, const and arrow functions differ from var and regular functions, including this.
  • You use destructuring, spread and rest, and know that spread copies one level deep.
  • You choose Map or Set over a plain object or array when keys or uniqueness call for it.
  • You can make an object iterable and explain what a generator gives you.

Concept questions, answered

The definitions and comparisons interviewers open with. Free to read, each with a full answer and examples.

What are the most important ES6 features in JavaScript?

ES6, officially ECMAScript 2015, was the largest update to JavaScript. Its most important features are let and const, arrow functions, classes, template literals, destructuring, spread and rest syntax, default parameters, ES modules with import and export, promises, Map and Set, symbols, and iterators with generators and for...of. Together they replaced most ES5 workarounds such as var hoisting, self = this and IIFE modules.

Read the full answer

What is the difference between var, let and const?

var is function scoped, can be redeclared and is hoisted with the value undefined. let and const are block scoped, cannot be redeclared in the same scope and cannot be used before their declaration. let can be reassigned, while const cannot be rebound. Use const by default, let when you must reassign, and avoid var.

Read the full answer

How are arrow functions different from regular functions?

Arrow functions are a shorter syntax with different behaviour. They have no this, arguments or super of their own and use those of the surrounding code. They cannot be called with new, have no prototype, and cannot be generators. Regular functions get their own this from how they are called.

Read the full answer

What is destructuring in JavaScript?

Destructuring is syntax that unpacks values from an array or properties from an object into separate variables in one statement. Instead of reading user.name and user.age line by line, you write const { name, age } = user. It also works in function parameters, loops and catch clauses.

Read the full answer

What is the difference between the spread and rest operators?

Spread and rest both use ..., but they do opposite jobs. Spread expands an array, string or object into separate values where you use it. Rest collects the remaining values into one array or object where you declare them, in function parameters or destructuring. Position decides which one you have.

Read the full answer

ES6 classes vs ES5 constructor functions: what changed?

ES6 classes use the same prototype system as ES5 constructor functions, but they are not just new syntax. A class must be called with new, runs in strict mode, has non-enumerable methods and is in the temporal dead zone until declared. extends sets up inheritance correctly, even for built-ins like Array and Error, and classes add super, private #fields and static blocks.

Read the full answer

Map vs object and Set vs array in JavaScript

Use a Map when you need a dictionary with arbitrary keys, a reliable size and frequent additions and removals. Use a plain object for fixed-shape records and JSON. Use a Set when you need unique values and fast membership checks, and an array when order, indexes or array methods matter.

Read the full answer

What is a Symbol in JavaScript used for?

A Symbol is a primitive value that is guaranteed to be unique, created by calling Symbol(). Its main use is as an object property key that can never collide with any other key, so libraries can add properties without clashing with yours. Built-in well-known symbols such as Symbol.iterator let objects plug into language features.

Read the full answer

What are generators in JavaScript?

A generator is a function declared with function* that can pause at each yield and resume later. Calling it does not run the body: it returns an iterator, and each next() call runs until the next yield. Generators produce values lazily, one at a time, and can receive values back.

Read the full answer

What are WeakMap and WeakSet used for?

WeakMap and WeakSet store objects without preventing them from being garbage collected. A WeakMap links extra data to an object key, and a WeakSet marks objects as members. When nothing else references the object, the entry disappears automatically, so they are used for metadata, caches and private data that must not leak memory.

Read the full answer

ES modules vs CommonJS: what is the difference?

ES modules (ESM) use import and export, are analysed before the code runs, and export live bindings. CommonJS (CJS) uses require() and module.exports, runs synchronously, and exports a value at the time of the call. ESM is the language standard for browsers and Node. CommonJS is the older Node format.

Read the full answer

What do optional chaining (?.) and nullish coalescing (??) do?

Optional chaining (?.) reads a property, index or method only if the value before it is not null or undefined; otherwise the whole expression returns undefined instead of throwing. Nullish coalescing (??) returns its right side only when the left side is null or undefined. Together, user?.address?.city ?? "Unknown" reads a nested value safely and supplies a default.

Read the full answer

Easy38

Medium44

Hard22

Practise with tests and full answers.

Every question has a runnable editor, tests and a step-by-step solution. Passes from ₹149, paid once; nothing renews.

Get full access
Rehearse it in a timed JavaScript mock interviewA real editor with tests, the follow-ups an interviewer asks, and a score out of 100.

Frequently asked

What are the most asked ES6 interview questions?

The difference between var, let and const, arrow functions and this, destructuring, spread versus rest, template literals, classes versus constructor functions, promises, Map versus an object, Set for removing duplicates, symbols, iterators and generators, and ES modules versus CommonJS.

Is ES6 the same as modern JavaScript?

ES6 is the 2015 edition, the biggest single update. A new edition has come out every year since, adding features such as async/await, optional chaining, nullish coalescing and array methods like at and toSorted. Interviews often say ES6 when they mean any of these.

Are ES6 classes just syntax over prototypes?

Mostly. Methods still live on the prototype and inheritance still uses the prototype chain. But classes add rules: they must be called with new, their bodies are in strict mode, they support private # fields, and a subclass must call super before using this.