22 JavaScript Interview Questions: Closures, Event Loop, this (2026)
22 JavaScript interview questions with sample answers: closures, the event loop output-order puzzle, this binding, debounce, structuredClone and ES2026.
Last updated: November 2026
Quick Answer
JavaScript interviewers test whether you can predict what the runtime will do: how scope and hoisting work, what a closure captures, what this points to, how the prototype chain resolves a property, and in what order the event loop runs synchronous code, microtasks and timers. Then they ask you to write something small and correct, such as debounce or Promise.all, under time pressure. Rehearse the spoken answers in OphyAI Interview Practice, and use OphyAI Coding Copilot for the live coding round. Every code sample below was run in Node.js and the printed output is shown as comments.
| # | Question | What it tests |
|---|---|---|
| 1 | var vs let vs const and the TDZ | Scope rules |
| 2 | What hoisting really does | Creation phase |
| 3 | Closures and the loop-with-setTimeout bug | Captured variables |
| 4 | How this is decided | Call-site binding |
| 5 | Arrow vs regular functions | Lexical this |
| 6 | The prototype chain | Property lookup |
| 7 | Are classes “just sugar”? | Object model |
| 8 | Event loop output order | Microtasks vs macrotasks |
| 9 | Promise.all vs allSettled vs race vs any | Async composition |
| 10 | == vs === | Coercion |
The Questions, With Sample Answers
1. “What is the difference between var, let and const?”
Why they ask. It is the opener in most screens, and the follow-up about the temporal dead zone (TDZ) separates people who memorized “use let” from people who know why.
Sample answer. “var is function-scoped and is initialized to undefined when the scope is created, so reading it before the assignment gives undefined. let and const are block-scoped, and although the engine knows about them from the start of the block, they are not initialized until the declaration line runs. That window is the temporal dead zone, and touching the variable inside it throws a ReferenceError. const prevents reassignment of the binding, not mutation of the value, so I can still change properties on a const object. My default is const, let when I genuinely reassign, and var only in legacy code.”
try { console.log(x); let x = 1; } catch (e) { console.log(e.message); }
// Cannot access 'x' before initialization
console.log(hoisted); var hoisted = 2; // undefined
const obj = { a: 1 }; obj.a = 2; // allowed: the binding is constant, the object is not
Weak answers. “let is not hoisted” with no mention of the TDZ, or “const makes an object immutable”.
2. “What is hoisting?”
Why they ask. Hoisting explains half of the “why does this print undefined” puzzles in a phone screen.
Sample answer. “Before running a scope, the engine registers every declaration in it. Function declarations are registered with their full body, so I can call one above the line where it is written. var declarations are registered and set to undefined, but the assignment stays where it is. let, const and class are registered but left uninitialized until their line, which is the TDZ. The practical trap is a function expression assigned to a var: the name exists early, but its value is undefined, so calling it early throws a TypeError, not a ReferenceError. Nothing is physically moved; hoisting is a way of describing that creation phase.”
console.log(sayHi()); function sayHi() { return 'hi'; } // hi
sayBye(); var sayBye = function () { return 'bye'; }; // TypeError: sayBye is not a function
Weak answers. “JavaScript moves declarations to the top of the file”, with no difference between functions, var and let.
3. “What is a closure? Why does this loop print 3, 3, 3?”
Why they ask. Closures underpin callbacks, React hooks, memoization and module patterns, and the loop puzzle is the classic check.
Sample answer. “A closure is a function together with the variables from the scope where it was created. The function keeps a live reference to those variables, not a copy, so it can read and update them after the outer function returns. That is how I build private state, like a counter that only exposes inc and get. In the loop, var i is one variable shared by every iteration, so by the time the timers fire it is 3. With let, each iteration gets a fresh binding, so each callback closes over its own value. Closures also explain some memory leaks: a long-lived callback keeps everything it references alive.”
for (var i = 0; i < 3; i++) setTimeout(() => console.log(i)); // 3 3 3
for (let j = 0; j < 3; j++) setTimeout(() => console.log(j)); // 0 1 2
Weak answers. “A function inside a function”, without saying what it captures or that the capture is by reference.
Rehearse the scope trio above out loud in Interview Practice, where a follow-up asks you to explain the output line by line.
4. “How is the value of this decided?”
Why they ask. Lost this is one of the most common production bugs in event handlers and callbacks.
Sample answer. “For a regular function, this depends on how the function is called, not where it is defined. Called as obj.method(), it is obj. Called as a plain function, it is undefined in strict mode and modules, or the global object in sloppy mode. call and apply set it explicitly for one call, bind returns a new function with this permanently fixed, and calling it later with call does not override that. With new, this is the freshly created object. The usual bug is pulling a method off its object, for example passing user.greet as a callback, which turns a method call into a plain call.”
'use strict';
const user = { name: 'Ada', greet() { return this.name; } };
const fn = user.greet;
fn(); // TypeError: Cannot read properties of undefined (reading 'name')
fn.call({ name: 'Grace' }); // 'Grace'
user.greet.bind({ name: 'Linus' }).call({ name: 'X' }); // 'Linus'
Weak answers. “this is the object the function belongs to”, which is wrong for every case except a direct method call.
5. “How are arrow functions different from regular functions?”
Why they ask. It tests whether you can choose between them rather than use arrows everywhere.
Sample answer. “An arrow function has no this, arguments, super or new.target of its own; it uses the ones from the surrounding scope. That makes arrows ideal for callbacks inside a method, like a setTimeout or map callback that needs the method’s this. It also means an arrow is the wrong choice for an object method that relies on this, or for a prototype method, because this will be whatever it was where the object literal was written. Arrows cannot be used with new and have no prototype property. For named, reusable top-level functions I often still prefer declarations because they are hoisted and show clearer names in stack traces.”
Weak answers. “Arrows are just shorter syntax.”
6. “Explain the prototype chain.”
Why they ask. Every class, method lookup and instanceof check runs on it.
Sample answer. “Every object has an internal link to another object, its prototype. When I read a property, the engine looks on the object itself, then on its prototype, then on that object’s prototype, until it reaches Object.prototype and finally null. Methods are usually stored once on the prototype and shared by all instances, which saves memory. Object.create(proto) makes an object with a chosen prototype, and Object.getPrototypeOf reads it. Writing a property always writes to the object itself, so it shadows the prototype’s value instead of changing it. To check own properties I use Object.hasOwn(obj, key) rather than in, which also walks the chain.”
const animal = { speak() { return `${this.name} makes a sound`; } };
const dog = Object.create(animal); dog.name = 'Rex';
dog.speak(); // 'Rex makes a sound'
Object.getPrototypeOf(dog) === animal; // true
Object.hasOwn(dog, 'speak'); // false
Weak answers. Describing classical inheritance from Java instead of delegation between objects.
7. “Are JavaScript classes just syntactic sugar?”
Why they ask. It checks whether you understand that classes sit on top of prototypes, and whether you know the modern class features.
Sample answer. “Mostly, but not entirely. A class is still a function, and its methods live on ClassName.prototype, so instances use the same prototype chain as before. But classes add real behavior: the body runs in strict mode, calling a class without new throws, class declarations are in the TDZ until defined, and extends sets up both instance and static inheritance correctly. Private fields with #, such as #balance, are enforced by the language, so they cannot be read from outside, unlike an underscore convention. Static fields and static blocks are also supported. I use classes when I have state plus behavior and several instances; otherwise plain functions and objects are simpler.”
class Account {
#balance = 0;
deposit(n) { this.#balance += n; return this.#balance; }
}
const a = new Account();
a.deposit(50); // 50
typeof Account; // 'function'
Object.keys(a); // [] (private fields are not properties)
Weak answers. “Yes, they are identical”, or not knowing that # fields exist.
8. “What does this code print, and why?”
Why they ask. This is the event loop question, and it appears in some form in most JavaScript interviews. Interviewers want the order and the reason.
console.log('1: sync start');
setTimeout(() => console.log('2: setTimeout'), 0);
Promise.resolve()
.then(() => console.log('3: promise.then'))
.then(() => console.log('4: second then'));
queueMicrotask(() => console.log('5: queueMicrotask'));
(async () => {
console.log('6: async fn body');
await null;
console.log('7: after await');
})();
console.log('8: sync end');
// Output (Node.js, both CommonJS and ES module):
// 1: sync start
// 6: async fn body
// 8: sync end
// 3: promise.then
// 5: queueMicrotask
// 7: after await
// 4: second then
// 2: setTimeout
Sample answer. “JavaScript runs one task at a time on a single call stack. First the whole script runs synchronously, so 1, 6 and 8 print; an async function runs synchronously until its first await. When the stack is empty, the engine drains the microtask queue completely before taking the next macrotask. Promise reactions, queueMicrotask callbacks and the code after an await are all microtasks, queued in the order they were scheduled: 3, 5, 7. Running 3 schedules its chained .then, so 4 joins the end of the same queue. Only after the microtask queue is empty does the timer, a macrotask, run, so 2 prints last even with a delay of 0.”
Weak answers. Saying setTimeout(fn, 0) runs immediately, or not knowing that a chained .then waits behind microtasks already queued.
Practice talking through output-order puzzles like this in a technical mock in OphyAI Interview Practice until the explanation takes under a minute.
9. “What is the difference between Promise.all, allSettled, race and any?”
Why they ask. Real code fans out requests, and choosing the wrong combinator either hides errors or fails too eagerly.
Sample answer. “Promise.all waits for every promise and gives me the values in input order, but rejects as soon as any one rejects. I use it when I need all results and one failure means the whole operation failed. Promise.allSettled never rejects; it gives me an array of {status, value} or {status, reason} objects, which suits dashboards that show partial data. Promise.race settles with whichever promise settles first, success or failure, which is how I build a timeout. Promise.any resolves with the first success and only rejects, with an AggregateError, if all of them fail, which suits trying several mirrors. None of them cancel the losing promises; for that I pass an AbortSignal to the underlying requests.”
Weak answers. Treating race and any as the same, or believing Promise.all stops the other requests.
10. “How does async/await work, and what are the common mistakes?”
Why they ask. Most modern Node.js and frontend code is written this way, and the performance mistakes are easy to spot in review.
Sample answer. “An async function always returns a promise. await pauses that function, not the thread, until the promise settles, then resumes it as a microtask; the rest of the program keeps running. Errors become rejections, so I handle them with try/catch around the await. Three mistakes come up again and again. First, awaiting independent calls one after another, which doubles latency; I start them together and await Promise.all. Second, using await inside forEach, which does not wait, so I use for...of for sequential work. Third, forgetting to await or return a promise, which turns a failure into an unhandled rejection that try/catch never sees.”
const user = await getUser(id); // sequential only when the second call needs the first
const [orders, prefs] = await Promise.all([getOrders(id), getPrefs(id)]); // parallel
Weak answers. “await blocks the thread”, or wrapping every line in its own try/catch.
11. “What is the difference between == and ===?”
Why they ask. Coercion rules are a fast filter, and the follow-up is usually about NaN and Object.is.
Sample answer. “=== is strict equality: no type conversion, so different types are never equal. == is loose equality: it converts operands following a set of rules, which produces results like 0 == '' being true and [] == false being true. The one loose comparison I find useful is value == null, which is true for both null and undefined and nothing else. Two edge cases matter in both operators: NaN is not equal to itself, and 0 === -0 is true. Object.is is the exception, treating NaN as equal to NaN and 0 as different from -0. For objects, all three compare references, not contents.”
0 == ''; // true
null == undefined; // true
null == 0; // false
NaN === NaN; // false
Object.is(NaN, NaN); // true
Weak answers. “== compares values and === compares types”, which misses that === also compares values.
12. “What is the difference between null and undefined?”
Why they ask. It leads into optional chaining, nullish coalescing and API design.
Sample answer. “undefined is what the language gives you when something has no value yet: an unassigned variable, a missing property, a missing argument, a function with no return. null is a value a programmer assigns on purpose to say ‘intentionally empty’. typeof null is 'object', a historical bug that cannot be fixed. They behave differently in practice: JSON.stringify drops keys whose value is undefined but keeps null, and default parameters apply for undefined but not for null. For fallbacks I use ??, which only replaces null and undefined, rather than ||, which also replaces 0 and the empty string. Optional chaining, a?.b, stops safely at either.”
0 || 10; // 10
0 ?? 10; // 0
JSON.stringify({ a: undefined, b: null }); // '{"b":null}'
Weak answers. “They are the same”, or using || for defaults where 0 is a valid value.
13. “How do you deep copy an object?”
Why they ask. Accidental shared references cause real bugs in state management and caches.
Sample answer. “Assignment copies the reference. Spread, Object.assign and Array.prototype.slice make shallow copies: a new outer object, but nested objects are still shared. For a real deep copy I use structuredClone, which is built into browsers and Node.js. It handles nested objects, arrays, Date, Map, Set, typed arrays and even circular references. It cannot clone functions or DOM nodes and throws a DataCloneError for them, and it does not preserve class prototypes, so a class instance comes back as a plain object. The old JSON.parse(JSON.stringify(x)) trick silently turns dates into strings and drops undefined, Map and Set, so I only use it for plain JSON data.”
const original = { user: { name: 'Ada' }, when: new Date(0), tags: new Set(['a']) };
const shallow = { ...original };
const deep = structuredClone(original);
original.user.name = 'Grace';
shallow.user.name; // 'Grace' (shared)
deep.user.name; // 'Ada'
deep.when instanceof Date; // true
JSON.parse(JSON.stringify(original)).tags; // {} (the Set is lost)
Weak answers. Calling spread a deep copy, or reaching for a library without knowing structuredClone exists.
14. “Implement debounce.”
Why they ask. It is one of the most common frontend coding questions because it combines closures, timers and this in ten lines.
Sample answer. “Debounce delays a function until calls have stopped for wait milliseconds, which suits a search box or a resize handler. I keep one timer in a closure. Each call clears the previous timer and starts a new one, so only the last call in a burst runs. I use a regular function for the wrapper so callers can use it as a method, and fn.apply(this, args) passes through both this and the latest arguments. Follow-ups I would mention: a leading option that fires on the first call, a cancel method for unmounting a component, and maxWait so a constant stream of events still fires occasionally. In React, the debounced function must be created once, not on every render.”
function debounce(fn, wait) {
let timer;
return function (...args) {
clearTimeout(timer);
timer = setTimeout(() => fn.apply(this, args), wait);
};
}
const search = debounce((q) => console.log('search:', q), 100);
search('j'); search('ja'); search('jav'); setTimeout(() => search('java'), 50);
// search: java (printed once)
Weak answers. Creating a new timer without clearing the old one, or losing this by using an arrow function for the returned wrapper.
15. “Now implement throttle. How is it different?”
Why they ask. It is the natural follow-up to debounce and tests whether you understand the two timing contracts.
Sample answer. “Throttle guarantees the function runs at most once per wait milliseconds during a continuous stream, which suits scroll position tracking or analytics pings, where I want regular updates rather than one at the end. Debounce waits for silence; throttle samples. My version runs the first call immediately, ignores calls inside the window, and schedules one trailing call with the latest arguments so the final position is not lost. In a test where I called it every 10 ms for 250 ms with a 100 ms window, it ran four times: the first call, two mid-stream calls and the last one.”
function throttle(fn, wait) {
let last = 0, timer = null, pendingArgs = null;
return function (...args) {
const remaining = wait - (Date.now() - last);
if (remaining <= 0) {
clearTimeout(timer); timer = null;
last = Date.now();
fn.apply(this, args);
} else {
pendingArgs = args;
if (!timer) {
timer = setTimeout(() => {
last = Date.now(); timer = null;
fn.apply(this, pendingArgs);
}, remaining);
}
}
};
}
Weak answers. Swapping the definitions of debounce and throttle, or a throttle that drops the final call.
For the live version of questions 14, 15 and 22, Coding Copilot in the desktop app reads the prompt from your screen and returns the approach, the code, a dry run with edge cases and the Big O.
16. “What is the difference between ES modules and CommonJS?”
Why they ask. Every Node.js and bundler setup forces this choice, and mixed setups break in confusing ways.
Sample answer. “CommonJS uses require and module.exports. It loads synchronously at runtime, so require can sit inside an if, and it returns the cached module.exports object, so values I destructure from it are copies that do not update. ES modules use import and export, are the standard in browsers and Node.js, and are analyzed before execution, which enables tree shaking and top-level await. ESM imports are live bindings, always strict mode, and have no __dirname; I use import.meta instead. Node.js picks the system from the file extension, .mjs or .cjs, or the type field in package.json. Recent Node.js versions can also require() an ES module as long as it has no top-level await, which has made interop much easier.”
Weak answers. “They are the same thing with different syntax.”
17. “Which array methods do you use most, and which ones mutate?”
Why they ask. Data transformation is daily work, and mutating shared arrays is a common React and Redux bug.
Sample answer. “Day to day I use map to transform, filter to select, reduce to aggregate, find and some to search, and flatMap to transform and flatten. For grouping, Object.groupBy is now built in. sort, reverse, splice, push, pop, shift and fill mutate the original array, while the newer toSorted, toReversed, toSpliced and with return copies, which is what I want for immutable state. Two classic traps: sort() with no comparator sorts as strings, so [10, 1, 5] becomes [1, 10, 5], and ['1', '2', '3'].map(parseInt) returns [1, NaN, NaN] because map passes the index as parseInt’s radix.”
const orders = [{ status: 'paid', total: 40 }, { status: 'refunded', total: 15 }, { status: 'paid', total: 25 }];
orders.filter((o) => o.status === 'paid').reduce((sum, o) => sum + o.total, 0); // 65
[10, 1, 5].sort(); // [1, 10, 5]
[10, 1, 5].toSorted((a, b) => a - b); // [1, 5, 10], original unchanged
Weak answers. Not knowing which methods mutate, or using forEach with a push where map would do.
18. “What are iterators and generators?”
Why they ask. They explain how for...of, spread and destructuring work, and generators show up in lazy pipelines and Redux-Saga style code.
Sample answer. “An iterator is an object with a next() method that returns { value, done }. An object is iterable if it has a [Symbol.iterator] method that returns an iterator, and that protocol is what for...of, spread and Array.from use. A generator function, written function*, returns an iterator whose body pauses at each yield and resumes on the next next(). That makes generators a neat way to write custom iterables and lazy, even infinite, sequences without building an array. Iterator helpers, standardized in ES2025, add map, filter, take and toArray directly on iterators, so a lazy pipeline over an infinite generator stops as soon as it has enough values.”
function* ids(start = 1) { let id = start; while (true) yield id++; }
ids().filter((n) => n % 2 === 0).map((n) => n * 10).take(3).toArray(); // [20, 40, 60]
Weak answers. Confusing generators with async functions, or not knowing what makes an object iterable.
19. “When would you use a WeakMap?”
Why they ask. It probes memory management, which matters in long-running Node.js services and single-page apps.
Sample answer. “A WeakMap holds its keys weakly: if nothing else references a key object, the garbage collector can reclaim it, and the entry disappears with it. Keys must be objects (or non-registered symbols), so set('str', 1) throws a TypeError. Because entries can vanish at any time, a WeakMap is not iterable and has no size. I use one to attach metadata or cache results per object, for example per DOM node or per request object, without causing a leak when that object goes away. A regular Map would keep every key alive forever. The same idea applies to WeakSet for tagging objects, and WeakRef exists for rarer cache cases.”
Weak answers. “It is a faster Map”, or not knowing why it cannot be iterated.
20. “How do you handle errors in JavaScript, sync and async?”
Why they ask. Swallowed errors and unhandled rejections are a frequent cause of silent production failures.
Sample answer. “Synchronous code uses try/catch/finally. A try block around a promise that is not awaited catches nothing, because the rejection happens later, so I always await inside the try or attach .catch. In Node.js an unhandled rejection crashes the process by default, which is the behavior I want rather than silent failure, and a global handler is for logging, not recovery. I throw Error objects rather than strings so I keep a stack trace, and I use custom subclasses such as ValidationError so callers can branch on the type. When I wrap a low-level error, I pass it as { cause } so the original is preserved for debugging.”
class ValidationError extends Error {
constructor(field, options) { super(`Invalid ${field}`, options); this.name = 'ValidationError'; }
}
try { JSON.parse('{bad'); } catch (err) { throw new ValidationError('payload', { cause: err }); }
// e.cause.name === 'SyntaxError'
Weak answers. Empty catch blocks, or throw 'something broke'.
21. “What is new in recent JavaScript versions?”
Why they ask. It is a cheap signal of whether you follow the language. You do not need everything; three accurate examples beat a long guessed list.
Sample answer. “The language ships one edition a year. ES2025 added iterator helpers, new Set methods like union, intersection and difference, Promise.try, RegExp.escape, import attributes with JSON modules, and Float16Array. ES2026, the 17th edition, added Array.fromAsync, Error.isError, Math.sumPrecise, base64 and hex conversion on Uint8Array, Iterator.concat, and Map.prototype.getOrInsert, which finally gives a clean way to write ‘get or set default’. Temporal, the replacement for Date, and explicit resource management with using are finished proposals that the TC39 list expects in ES2027. Support varies by runtime version, so before using one in an interview I would check it runs in the editor’s Node.js version.”
Weak answers. Listing ES2015 features as “new”, or naming proposals that have not reached Stage 4 as shipped.
22. Live coding: “Implement Promise.all from scratch.”
Why they ask. It combines promises, closures and edge cases, and is a staple of senior frontend and Node.js loops.
Sample answer. “I return a new promise. I keep a results array the same length as the input and a counter of how many are still pending. For each item I call Promise.resolve(item) so plain values work too, and in its then I store the value at the item’s original index, not the order it finished, then decrement the counter and resolve when it hits zero. The first rejection calls reject, and later settlements are ignored because a promise can only settle once. The edge case people miss is an empty array, which must resolve immediately with [], otherwise the promise hangs. Complexity is O(n) beyond the time of the slowest promise.”
function promiseAll(items) {
return new Promise((resolve, reject) => {
const results = new Array(items.length);
let remaining = items.length;
if (remaining === 0) return resolve(results);
items.forEach((item, i) => {
Promise.resolve(item).then((value) => {
results[i] = value;
if (--remaining === 0) resolve(results);
}, reject);
});
});
}
const wait = (ms, v) => new Promise((r) => setTimeout(() => r(v), ms));
promiseAll([wait(30, 'a'), 2, wait(10, 'c')]).then(console.log); // [ 'a', 2, 'c' ]
promiseAll([]).then(console.log); // []
Weak answers. Pushing results in completion order, or forgetting the empty-array case.
React-specific questions such as hooks, re-renders and Server Components are covered separately in our React interview questions.
How to Practice These
Run a voice or text mock in OphyAI Interview Practice, which asks follow-up questions and returns a transcript with per-answer feedback, so you find out whether your event loop explanation survives “and what if I add another then?”. For live coding rounds, OphyAI Coding Copilot (desktop app, Premium plan, 15 credits a session) snaps the problem window with Cmd/Ctrl+Shift+A, or transcribes a question asked out loud, and shows an answer card with how it read the problem, what to say first, the code, a dry run and the Big O. For the conversational parts of a live video interview, OphyAI Interview Copilot gives real-time suggestions on Zoom, Microsoft Teams and Google Meet. Start practicing →
A simple routine: each day, answer four concept questions aloud in under two minutes each, then write one utility (debounce, throttle, Promise.all, a deep-equal function, an event emitter) from memory in a plain editor and run it in Node.js. If you want more structured coding drills, see our coding interview practice page and the coding interview patterns guide.
Frequently Asked Questions
What JavaScript topics come up most in interviews?
Scope and hoisting, closures, this, prototypes and classes, the event loop, promises and async/await, equality and type coercion, and array methods come up in most technical screens. Frontend loops add the DOM, events and a framework such as React, while Node.js loops add modules, streams and error handling. Coding rounds often ask for small utilities like debounce.
Is JavaScript a good language for coding interviews?
Yes, for most general software engineering interviews where you can choose the language. It has concise syntax, first-class functions and built-in Map and Set. The weak spots are that it has no built-in heap or priority queue and that sort() compares strings by default, so practice writing a comparator and a small heap before a data structures round.
Should I prepare TypeScript as well?
If the job description mentions TypeScript, yes: expect questions on interfaces versus type aliases, generics, union and literal types, type narrowing, unknown versus any, and utility types such as Partial and Pick. The runtime questions on this page still apply, because TypeScript compiles to JavaScript and the types are erased, so closures and the event loop behave exactly the same.
Which Node.js version should I know about?
Know that Node.js has even-numbered long-term support lines. According to the Node.js release schedule, Node.js 26 entered Active LTS in October 2026, Node.js 24 and 22 are in maintenance, and Node.js 20 reached end of life in April 2026. Saying which version your last project used, and why, is more useful than reciting the schedule.
How do I answer JavaScript questions without sounding memorized?
Give a one-sentence definition, a short code example you can type from memory, and one bug you have actually seen it cause. For closures, mention a stale value in a callback; for this, a handler that lost its object. Interviewers follow up on your example, so pick one you can discuss for two minutes and predict output for.
How long does it take to prepare for a JavaScript interview?
If you write JavaScript every day, one to two weeks of concept review plus a daily coding problem is a common plan. Coming from another language, allow three to four weeks to get comfortable with async behavior and the object model. These are typical ranges from prep guides, not a rule; adjust for the role’s level and the number of rounds.
How does OphyAI work in a JavaScript coding interview?
Rehearse the spoken questions, such as the event loop or this, in Interview Practice. For the coding round, Coding Copilot in the desktop app reads the problem with Cmd/Ctrl+Shift+A or a dragged box with Cmd/Ctrl+Shift+S, remembers it for follow-ups, and shows the code with a dry run in an overlay left out of screen sharing. It is not hidden from a webcam, keystroke history or proctoring software.
Related Guides
- Meta interview guide
- Google interview guide
- Airbnb interview guide
- Stripe interview guide
- Shopify interview guide
- Uber interview guide
- DoorDash interview guide
- Revolut frontend interview
- React interview questions
- Angular interview questions
- Python interview questions
- Java interview questions
- Coding interview examples and solutions
- Technical interview prep for software engineers
Sources and verification notes
Sources checked November 2026. Every complete code sample was run in Node.js 22 and the outputs shown are the actual printed results; the two-line fragment in question 10 calls placeholder functions and was not run. ES2025 and ES2026 features newer than Node.js 22’s engine (such as Promise.try and Map.prototype.getOrInsert) are described from the specification and proposal list, not run. The sample answers are original templates, not questions published by any employer.
- TC39, Finished Proposals: expected publication year for each Stage 4 proposal (ES2025: iterator helpers, Set methods,
Promise.try,RegExp.escape, import attributes and JSON modules, Float16; ES2026:Array.fromAsync,Error.isError,Math.sumPrecise, Uint8Array base64, iterator sequencing, upsert; ES2027: Temporal, explicit resource management). - ECMAScript 2026 Language Specification: the seventeenth edition, including
Error.isError,Iterator.concatandMap.prototype.getOrInsert. - Node.js release schedule (nodejs/Release) and Node.js releases: Node.js 26 (Lithium) LTS from October 28, 2026; Node.js 24 maintenance from October 20, 2026; Node.js 22 end of life April 30, 2027; Node.js 20 end of life April 30, 2026.
- Node.js docs, Loading ECMAScript modules using require(): supported for fully synchronous modules, unflagged since v22.12.0 and no longer experimental since v25.4.0.
- MDN, let and the temporal dead zone
- MDN, Using microtasks with queueMicrotask()
- MDN, structuredClone(): deep copy,
DataCloneErrorfor uncloneable values. - MDN, WeakMap
- MDN, JavaScript modules
Tags:
Share this article:
Rehearse your answers, then get live help on the call.
Practice free for up to 15 minutes, then use Interview Copilot in the OphyAI desktop app: real-time answer suggestions on Zoom, Teams and Google Meet, in a window hidden from screen sharing.
On your phone? Practice interview answers in the OphyAI app.
Hidden from screen share and recording; a webcam or a person in the room can still see your screen.
Related Articles
22 C++ Interview Questions: RAII, Move Semantics, UB & C++26
Interview Tips
22 cpp interview questions with tested sample answers: RAII, smart pointers, move semantics, vtables, undefined behavior, atomics, C++23 and C++26.
Read more →
Angular Interview Questions: 22 Answers on Signals, v22 & RxJS
Interview Tips
22 Angular interview questions with sample answers: signals, OnPush by default in v22, zoneless, @defer, switchMap vs mergeMap, DI, forms and live coding.
Read more →
React Interview Questions: 23 Answers on Hooks, React 19 & Coding
Interview Tips
23 React interview questions with sample answers: keys, useEffect cleanup, React.memo, Context vs Redux, React 19 Actions, Server Components and live coding.
Read more →