Interview preparation

ES6+ (Modern JavaScript) Interview Questions

Answers written to be said out loud in an interview — each with a common follow-up question and a link to the tutorial that explains it in depth.

Beginner
8
Intermediate
9
Experienced
8
01What is ECMAScript and how does it relate to JavaScript?Beginner

ECMAScript is the language specification; JavaScript is the most widely used implementation. ES6 (ES2015) was a major update, and new editions now appear every year.

Learn more: ES6+ (Modern JavaScript) — Introduction to ECMAScript
02How do arrow functions differ from regular functions?Beginner

Arrow functions are shorter, do not have their own this, arguments or super, cannot be used with new, and implicitly return a single expression when written without braces.

Learn more: ES6+ (Modern JavaScript) — Arrow Functions
03Spread vs rest — what is the difference?Beginner

Both use …. Spread expands an iterable or object into individual elements ([...a, ...b], { ...obj }). Rest collects remaining elements into an array or object (function f(...args), const { id, ...rest } = obj).

Learn more: ES6+ (Modern JavaScript) — Spread Operator
04Why were let and const added?Beginner

var is function-scoped and can be redeclared, which causes bugs in loops and blocks. let and const are block-scoped, cannot be redeclared in the same scope and throw if used before declaration. Default to const and use let when you need to reassign.

Learn more: ES6+ (Modern JavaScript) — let and const
05What are template literals?Beginner

Strings in backticks that support ${expression} interpolation and real line breaks. Tagged templates pass the pieces to a function, which libraries use for safe HTML, SQL or CSS.

Learn more: ES6+ (Modern JavaScript) — Template Literals
06How do default parameters work?Beginner

A default value is used when the argument is undefined (missing or passed as undefined), not when it is null. Defaults are evaluated at call time and can refer to earlier parameters.

Learn more: ES6+ (Modern JavaScript) — Default Parameters
07What is destructuring?Beginner

Syntax for unpacking values: const { name, age } = user takes properties; const [first, second] = list takes array items by position. You can rename, set defaults and collect the rest with ...rest.

JavaScript Illustrative
const { name, role = 'student', ...rest } = { name: 'Asha', city: 'Pune' };
const [first, , third] = [10, 20, 30];
let a = 1, b = 2;
[a, b] = [b, a];
Learn more: ES6+ (Modern JavaScript) — Destructuring
08What are enhanced object literals?Beginner

Shorthands inside object literals: property shorthand ({ name } instead of { name: name }), method shorthand (greet() {}), and computed keys ({ [key]: value }).

Learn more: ES6+ (Modern JavaScript) — Enhanced Object Literals
09What are ES modules and how do named and default exports differ?Intermediate

ES modules use import/export with static structure, which enables tree-shaking. A module can have many named exports (imported by exact name in braces) and at most one default export (imported with any name).

Learn more: ES6+ (Modern JavaScript) — Modules
10What are Map and Set, and when are they better than objects and arrays?Intermediate

Map stores key-value pairs with keys of any type, keeps insertion order and has a size property. Set stores unique values. Use Map for frequent additions/removals or non-string keys, and Set for de-duplication and fast membership checks.

JavaScript Illustrative
const unique = [...new Set([1, 2, 2, 3])]; // [1, 2, 3]
Learn more: ES6+ (Modern JavaScript) — Map and Set
11What is a Symbol?Intermediate

A unique, immutable primitive often used as a non-colliding object key. Well-known symbols such as Symbol.iterator let you customise built-in language behaviour.

Learn more: ES6+ (Modern JavaScript) — Symbols
12What does optional chaining do?Intermediate

?. stops and returns undefined if the value on its left is null or undefined, instead of throwing. It works for properties (user?.address), indexes (list?.[0]) and calls (callback?.()).

Learn more: ES6+ (Modern JavaScript) — Optional Chaining
13?? vs || — what is the difference?Intermediate

|| falls back for any falsy value (0, "", false, NaN, null, undefined). ?? falls back only for null and undefined, so a real 0 or empty string is kept.

Learn more: ES6+ (Modern JavaScript) — Nullish Coalescing
14What are ES6 classes and what do they not change?Intermediate

class, constructor, extends, super and static give clear syntax for constructor functions and prototypes. JavaScript is still prototype-based underneath, and class declarations are hoisted but stay in the temporal dead zone.

Learn more: ES6+ (Modern JavaScript) — Classes
15How do iterators and the for…of loop work?Intermediate

An object is iterable if it has a [Symbol.iterator]() method that returns an iterator with next() → { value, done }. for…of, spread, destructuring and Array.from all use this protocol.

Learn more: ES6+ (Modern JavaScript) — Iterators
16What do async/await add on top of promises?Intermediate

An async function always returns a promise, and await pauses that function until a promise settles, so asynchronous code reads top to bottom and errors are handled with try/catch. It is still promises underneath — nothing becomes synchronous.

Learn more: ES6+ (Modern JavaScript) — Async and Await
17How do you make an object immutable?Intermediate

Object.freeze prevents adding, removing and changing properties, but only shallowly. For deep immutability, freeze recursively or create updated copies with spread instead of mutating.

Learn more: ES6+ (Modern JavaScript) — Enhanced Object Literals
18What are dynamic imports and why use them?Experienced

import("./module.js") loads a module at runtime and returns a promise. It enables code splitting and lazy loading — for example loading a heavy chart library only when a user opens a dashboard.

Learn more: ES6+ (Modern JavaScript) — Dynamic Imports
19Name some modern array methods and their benefits.Experienced

flat/flatMap, at() for negative indexing, findLast/findLastIndex, and the non-mutating toSorted, toReversed, toSpliced and with(), which return copies — ideal for immutable state updates in React.

Learn more: ES6+ (Modern JavaScript) — Modern Array Methods
20What are generators good for in practice?Experienced

Producing values lazily — infinite sequences, paging through APIs, walking trees — because the function pauses at each yield. They can also receive values via next(value). Async generators with for await…of stream asynchronous data.

Learn more: ES6+ (Modern JavaScript) — Generators
21Which ES2015+ features need a polyfill rather than transpilation?Experienced

Syntax (arrow functions, classes, destructuring) can be transpiled. New built-ins (Promise, Map, Array.prototype.includes, Object.entries, structuredClone) must be polyfilled because they are runtime APIs.

Learn more: ES6+ (Modern JavaScript) — ES6 vs Older JavaScript
22What new array methods avoid mutating the original?Experienced

toSorted, toReversed, toSpliced and with return new arrays, unlike sort, reverse and splice. Combined with at(-1), findLast and Object.groupBy, they make immutable updates easier in React and Redux code.

Learn more: ES6+ (Modern JavaScript) — Modern Array Methods
23Static import vs dynamic import()?Experienced

Static imports are hoisted, analysed at build time and enable tree shaking. import() returns a promise and loads a module on demand, creating a separate chunk — ideal for routes, heavy libraries or feature flags.

Learn more: ES6+ (Modern JavaScript) — Dynamic Imports
24What are well-known symbols?Experienced

Built-in symbols such as Symbol.iterator, Symbol.asyncIterator, Symbol.toPrimitive and Symbol.hasInstance let your objects hook into language behaviour: iteration, conversion and instanceof.

Learn more: ES6+ (Modern JavaScript) — Symbols
25What is the difference between Promise.then chains and async/await for error handling?Experienced

With .then, errors flow to the next .catch in the chain. With await, a rejected promise throws at that line, caught by try/catch. Forgetting to await or return a promise inside either style creates a floating promise whose errors are lost.

Learn more: ES6+ (Modern JavaScript) — Promises