JavaScript Interview Questions and Answers: 2027 Edition With Runnable Code
javascript-interview-questions is a free, practical set of JavaScript interview questions with answers and code, for frontend, full-stack and Node.js developers preparing for junior, mid-level and senior interviews. It covers the questions interviewers keep asking (closures, this, hoisting, prototypes, the event loop, promises and async/await, equality and coercion, modules, memory) plus the “implement it yourself” coding round: debounce, throttle, Promise.all, deep clone, curry, bind, an event emitter and an LRU cache. Every coding answer is in src/ and tested in test/ with Node’s built-in test runner, so you can run, break and re-check each one.
Last reviewed: December 2026. Language notes refer to ECMAScript 2026 (approved June 2026) and features already at Stage 4 for ES2027, such as Temporal and
using. Runtime support changes fast: check the linked MDN page before you rely on a newer API in production.
git clone https://github.com/Ralpberry-Labs/javascript-interview-questions
cd javascript-interview-questions
npm test # node --test, Node 22 or newer, no dependencies
node src/event-loop-order.mjs # predict the output first
Table of Contents
- How to Use This List
- A 3-Week Preparation Plan
- 1. Basics, Types and Values
- 2. Equality and Type Coercion
- 3. Scope, Hoisting and Closures
- 4. The
thisKeyword - 5. Objects, Prototypes and Classes
- 6. Functions and Functional Patterns
- 7. Arrays, Maps, Sets and Iteration
- 8. The Event Loop
- 9. Promises and Async/Await
- 10. Modules
- 11. Errors and Debugging
- 12. Memory and Performance
- 13. Modern JavaScript: ES2020 to ES2027
- 14. JavaScript in the Browser
- 15. Coding Round: Implement It Yourself
- 16. Output Prediction Questions
- Practice Problems on LeetCode
- Best Resources to Prepare
- FAQ
- Where to Go Next
- Contributing
- License
How to Use This List
- Levels: [J] junior, [M] mid-level, [S] senior. Senior candidates get junior questions too; the bar is a deeper answer with trade-offs and real examples.
- Say it out loud first. Interviews test explanation, not recall. Answer each question in two or three sentences before reading ours.
- Run the code. Each “implement it” question links to a file in
src/and its test. Delete the body, rewrite it, and runnpm test. - Predict, then run. For output questions, write down your answer before checking. Getting the event-loop order wrong once is the fastest way to learn it.
A 3-Week Preparation Plan
| Week | Focus | Daily time | Done when you can… |
|---|---|---|---|
| 1 | Sections 1 to 6: types, coercion, scope, closures, this, prototypes |
1 to 1.5 h | Explain closures and this with your own example, and draw a prototype chain |
| 2 | Sections 7 to 11: arrays, event loop, promises, modules, errors | 1.5 h | Predict any output question in section 16 and explain why |
| 3 | Section 15 coding round + LeetCode JavaScript problems | 1.5 to 2 h | Write debounce, throttle, Promise.all, deep clone and an event emitter from a blank file in under 15 minutes each |
If you only have a weekend: closures, this, the event loop, promises, and the five coding exercises above. Those come up in most JavaScript screens.
1. Basics, Types and Values
Q1. What are the data types in JavaScript? [J]
Seven primitive types plus objects:
| Type | Example | typeof |
|---|---|---|
undefined |
let x; |
"undefined" |
null |
null |
"object" (a historical bug, kept for compatibility) |
boolean |
true |
"boolean" |
number |
42, 3.14, NaN, Infinity |
"number" |
bigint |
9007199254740993n |
"bigint" |
string |
"hi" |
"string" |
symbol |
Symbol("id") |
"symbol" |
| object | {}, [], functions, dates, maps |
"object" (functions give "function") |
Primitives are immutable and compared by value. Objects are mutable and compared by reference.
Q2. What is the difference between null and undefined? [J]
undefined means “no value was assigned”: an uninitialized variable, a missing property, a missing argument, a function with no return. null is a value you assign on purpose to say “empty”. null == undefined is true, null === undefined is false. Default parameters and destructuring defaults kick in only for undefined, not null.
Q3. What is the difference between var, let and const? [J]
var |
let |
const |
|
|---|---|---|---|
| Scope | Function | Block | Block |
| Hoisted | Yes, initialized to undefined |
Yes, but in the temporal dead zone until declared | Same as let |
| Re-declare in same scope | Allowed | Error | Error |
| Re-assign | Allowed | Allowed | Error |
Creates window property at top level (scripts) |
Yes | No | No |
const stops re-assignment, not mutation: const arr = []; arr.push(1) works. Use const by default, let when the value must change, and avoid var in new code.
Q4. Why does 0.1 + 0.2 !== 0.3? [J]
Numbers are IEEE 754 double-precision floats. 0.1 and 0.2 have no exact binary representation, so their sum is 0.30000000000000004. Compare with a tolerance (Math.abs(a - b) < Number.EPSILON * 4 for values near 1), work in integer cents for money, or use a decimal library. Math.sumPrecise (ES2026) gives a correctly rounded sum of many floats, but it does not make 0.1 exact.
Q5. What is NaN, and how do you check for it? [J]
NaN (“not a number”) is the result of failed numeric operations like Number("abc") or 0 / 0. It is the only value not equal to itself: NaN === NaN is false. Use Number.isNaN(x). The global isNaN(x) converts its argument first, so isNaN("abc") is true, which is usually not what you want. Object.is(NaN, NaN) is true.
Q6. What is the largest safe integer, and what is BigInt for? [M]
Number.MAX_SAFE_INTEGER is 2^53 − 1 (9007199254740991). Above it, not every integer can be represented, so 2 ** 53 + 1 === 2 ** 53 is true. BigInt (123n) stores arbitrary-size integers. You cannot mix BigInt and number in arithmetic without converting (1n + 1 throws a TypeError), and JSON.stringify throws on a BigInt unless you supply a replacer. Typical uses: 64-bit IDs from databases or APIs, cryptography, exact integer math.
Q7. Primitive wrappers: why does "abc".length work? [M]
When you read a property on a primitive, JavaScript temporarily wraps it in an object (String, Number, Boolean, Symbol, BigInt) so the method lookup works, then throws the wrapper away. That is why "abc".toUpperCase() works but const s = "abc"; s.custom = 1; s.custom is undefined. Never create wrappers yourself with new String("x"): typeof returns "object" and the object is always truthy, even new Boolean(false).
Q8. What are truthy and falsy values? [J]
The falsy values are false, 0, -0, 0n, "", null, undefined and NaN (plus the legacy document.all in browsers). Everything else is truthy, including "0", "false", [] and {}. A common bug: if (count) treats a real count of 0 as “missing”. Use count !== undefined or count ?? defaultValue.
Q9. What is the difference between ?? and ||? [J]
a || b returns b when a is any falsy value. a ?? b returns b only when a is null or undefined. So 0 || 10 is 10 but 0 ?? 10 is 0. Use ?? for defaults when 0, "" or false are valid values. The assignment forms ||=, &&= and ??= (ES2021) only assign when the condition holds.
Q10. What does optional chaining (?.) do? [J]
a?.b returns undefined instead of throwing when a is null or undefined, and it stops evaluating the rest of the chain. It works for calls (fn?.()) and brackets (obj?.[key]). Do not sprinkle it everywhere: if a value should never be missing, a loud error is better than a silent undefined that breaks something later.
2. Equality and Type Coercion
Q11. What is the difference between == and ===? [J]
=== (strict equality) compares without converting types. == (loose equality) converts operands first by a set of rules: null and undefined only equal each other, booleans become numbers, strings compared with numbers become numbers, objects compared with primitives are converted with valueOf/toString. Use === everywhere. The one common, intentional use of == is x == null to check for both null and undefined.
Q12. What is Object.is, and how does it differ from ===? [M]
Object.is is the “SameValue” comparison. It matches === except for two cases: Object.is(NaN, NaN) is true and Object.is(0, -0) is false. React uses it to decide whether state changed. Map, Set and Array.prototype.includes use “SameValueZero”, which treats NaN as equal to itself and 0 as equal to -0.
Q13. Explain these coercion results. [M]
[] + [] // "" both arrays become "" via toString
[] + {} // "[object Object]"
1 + "2" // "12" + with a string concatenates
"3" - 1 // 2 - always converts to numbers
true + true // 2
[] == false // true [] -> "" -> 0, false -> 0
null == 0 // false null only loosely equals undefined
null >= 0 // true relational operators convert null to 0
"b" + "a" + +"a" + "a" // "baNaNa" +"a" is NaN
The rule interviewers want: + concatenates if either side becomes a string after converting objects to primitives; other arithmetic operators convert to numbers. Being able to explain two or three of these beats memorizing all of them.
Q14. How do objects convert to primitives? [S]
JavaScript calls obj[Symbol.toPrimitive](hint) if it exists, where the hint is "number", "string" or "default". Otherwise it tries valueOf() then toString() (or the reverse for the "string" hint) and uses the first one that returns a primitive. Date prefers string for +, which is why new Date() + 1 produces a string.
const money = {
amount: 42,
[Symbol.toPrimitive](hint) {
return hint === 'string' ? `$${this.amount}` : this.amount;
},
};
`${money}` // "$42"
money * 2 // 84
3. Scope, Hoisting and Closures
Q15. What is hoisting? [J]
Declarations are processed before code runs, so they exist from the start of their scope:
functiondeclarations are hoisted with their body. You can call them before the line they appear on.varis hoisted and initialized toundefined.let,constandclassare hoisted but not initialized. Touching them before the declaration throws aReferenceError. That window is the temporal dead zone (TDZ).- Function expressions and arrow functions follow the rules of the variable they are assigned to.
sayHi(); // works
console.log(a); // undefined
console.log(b); // ReferenceError: Cannot access 'b' before initialization
function sayHi() {}
var a = 1;
let b = 2;
Q16. What is lexical scope? [J]
A function can see variables from the place where it was written, not where it is called. Scopes nest: block inside function inside module. Lookup walks outward until it finds the name or reaches the global scope.
Q17. What is a closure? [J]
A closure is a function together with the variables it captured from the scope where it was created. The function keeps access to those variables after the outer function has returned.
function makeCounter() {
let count = 0; // private: only the returned functions can touch it
return {
increment: () => ++count,
get: () => count,
};
}
const c = makeCounter();
c.increment();
c.get(); // 1
Real uses: private state, function factories, memoization caches, event handlers that remember their context, and every debounce/throttle in src/functions.mjs.
Q18. Why does this loop print 3, 3, 3, and how do you fix it? [J]
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 0);
}
// 3, 3, 3
var creates one i for the whole function. By the time the callbacks run, the loop has finished and i is 3. Fix: use let, which creates a fresh binding for each iteration, so you get 0, 1, 2. The pre-2015 fix was an IIFE that passed i as an argument.
Q19. Can closures cause memory leaks? [M]
A closure keeps its captured variables alive as long as the closure itself is reachable. If a long-lived object (a global, a cache, a DOM listener that is never removed) holds a closure that captured a large array, that array cannot be garbage collected. Fix: remove listeners (AbortController makes this easy), avoid capturing more than you need, and clear caches. Engines generally retain only variables some inner function actually references, but all closures created in the same scope may share one context, so one closure can keep another’s captured data alive.
Q20. What is an IIFE and is it still useful? [J]
An Immediately Invoked Function Expression runs as soon as it is defined: (function () { /* private scope */ })();. It was the standard way to create private scope before block scoping and modules. Today modules and let/const cover most uses, but you still see IIFEs for running async code at the top level of a script that is not a module: (async () => { await main(); })();.
Q21. What is the difference between global scope in a script and in a module? [M]
In a classic script, top-level var and function declarations become properties of the global object (window in browsers). In an ES module, top-level declarations are scoped to the module, this is undefined at the top level, strict mode is always on, and top-level await is allowed.
4. The this Keyword
Q22. How is this determined? [J]
For regular functions, this is decided by how the function is called, in this order of priority:
new Fn()→ the newly created object.fn.call(obj),fn.apply(obj), or a function made byfn.bind(obj)→obj.obj.fn()→obj(the thing before the dot).- Plain call
fn()→undefinedin strict mode (modules and classes are always strict), the global object in sloppy mode.
Arrow functions have no this of their own. They use this from the surrounding scope at creation time, and call/apply/bind cannot change it.
Q23. Why does this get lost in callbacks? [J]
class Timer {
seconds = 0;
start() {
setInterval(function () {
this.seconds++; // `this` is not the Timer here
}, 1000);
}
}
The callback is called as a plain function, so rule 4 applies. Fixes: an arrow function (setInterval(() => this.seconds++, 1000)), .bind(this), or a class field arrow method (tick = () => { this.seconds++; }). The same problem happens when you pass obj.method as a callback: button.addEventListener('click', obj.method) loses obj.
Q24. What are call, apply and bind? [J]
All three set this. call(thisArg, a, b) invokes immediately with listed arguments. apply(thisArg, [a, b]) invokes immediately with an array. bind(thisArg, a) returns a new function with this fixed and optional arguments pre-filled (partial application). You can see how each works in src/polyfills.mjs (myCall, myBind).
Q25. When should you not use an arrow function? [M]
- Object methods that need
thisto be the object:{ count: 0, inc: () => this.count++ }does not work. - Prototype methods and constructors: arrows cannot be used with
newand have noprototype. - Functions that need
arguments: arrows do not have their own (use rest parameters instead). - DOM handlers that rely on
thisbeing the element.
5. Objects, Prototypes and Classes
Q26. What is prototypal inheritance? [J]
Every object has an internal link ([[Prototype]]) to another object or null. When you read a property that is not on the object, JavaScript looks it up on the prototype, then the prototype’s prototype, and so on until null. That chain is how arrays get map (from Array.prototype) and how every object gets toString (from Object.prototype). Writing a property always writes to the object itself, never up the chain (unless a setter on the chain intercepts it).
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
Q27. What is the difference between __proto__, prototype and Object.getPrototypeOf? [M]
Fn.prototypeis a normal property on functions. It becomes the[[Prototype]]of objects created withnew Fn().obj.__proto__is a legacy accessor for an object’s[[Prototype]]. It works in browsers but is deprecated in favor of the next item.Object.getPrototypeOf(obj)/Object.setPrototypeOf(obj, p)are the standard ways to read and change it. Changing a prototype after creation is slow; preferObject.create(p).
Q28. What does new do? [M]
- Creates an empty object whose prototype is
Fn.prototype. - Calls
Fnwiththisbound to that object. - Returns the object, unless
Fnexplicitly returns another object.
See myNew in src/polyfills.mjs for these steps as code.
Q29. Are JavaScript classes “real” classes? [M]
class is mostly cleaner syntax over prototypes: methods go on Fn.prototype, extends sets up the prototype chain. But classes add real differences too: the body is always strict, class constructors throw if called without new, class declarations are in the TDZ until defined, methods are non-enumerable, and classes support private fields (#x), static blocks and super.
class Account {
#balance = 0; // truly private, not just a convention
static #count = 0;
constructor(owner) { this.owner = owner; Account.#count++; }
deposit(n) { if (n <= 0) throw new RangeError('positive only'); this.#balance += n; }
get balance() { return this.#balance; }
static get count() { return Account.#count; }
static isAccount(x) { return #balance in x; } // ergonomic brand check (ES2022)
}
Q30. How do private fields (#x) differ from a _x convention or a closure? [M]
_x is only a naming convention; anyone can read it. #x is enforced by the language: accessing it outside the class body is a syntax error, it does not show up in Object.keys or JSON.stringify, and a Proxy cannot intercept it. Closures also give privacy but need one function per instance. Private fields work with normal prototype methods.
Q31. Shallow copy vs deep copy? [J]
A shallow copy ({ ...obj }, Object.assign({}, obj), [...arr], arr.slice()) copies the top level only; nested objects are shared. A deep copy copies everything. Use structuredClone(value), which handles nested objects, Date, Map, Set, typed arrays and circular references. It does not copy functions, DOM nodes or class prototypes (class instances come back as plain objects). JSON.parse(JSON.stringify(x)) is a weaker fallback: it drops undefined and functions, turns dates into strings, and throws on cycles and BigInt. For the interview version, see deepClone in src/objects.mjs.
Q32. What do Object.freeze, Object.seal and Object.preventExtensions do? [M]
| Add props | Delete props | Change values | |
|---|---|---|---|
preventExtensions |
No | Yes | Yes |
seal |
No | No | Yes |
freeze |
No | No | No |
All three are shallow: nested objects stay mutable unless you freeze them too. In strict mode, forbidden writes throw a TypeError; in sloppy mode they fail silently.
Q33. What are property descriptors, getters and setters? [M]
Every property has attributes: value, writable, enumerable, configurable (data properties) or get/set (accessor properties). Object.defineProperty(obj, 'id', { value: 1, writable: false }) creates a read-only property. Getters compute a value on read (get fullName() { return ${this.first} ${this.last} }); setters validate on write. Object.getOwnPropertyDescriptors plus Object.defineProperties copies an object including its getters, which spread syntax does not do (spread reads the getter’s current value).
Q34. What is a Proxy and when is it used? [S]
A Proxy wraps an object and intercepts operations (get, set, has, delete, function calls) through handler “traps”. Reflect provides the default behavior for each trap. Real uses: Vue 3’s reactivity system, validation layers, logging, default values, and mocking in tests. Downsides: overhead on every access, and some built-ins with internal slots (Map, Date) need extra handling.
const withDefault = (obj, fallback) =>
new Proxy(obj, { get: (t, k, r) => (Reflect.has(t, k) ? Reflect.get(t, k, r) : fallback) });
withDefault({ a: 1 }, 0).b; // 0
Q35. What are Symbols used for? [M]
A Symbol is a unique primitive, mainly used as a property key that cannot clash with other keys. Well-known symbols let you hook into language behavior: Symbol.iterator (make an object iterable with for...of), Symbol.asyncIterator, Symbol.toPrimitive, Symbol.hasInstance. Symbol.for('key') returns a shared symbol from a global registry. Symbol-keyed properties are skipped by Object.keys, for...in and JSON.stringify.
6. Functions and Functional Patterns
Q36. Function declaration vs function expression vs arrow function? [J]
A declaration (function f() {}) is hoisted with its body. An expression (const f = function () {}) is created when that line runs. An arrow (const f = () => {}) is an expression with lexical this, no arguments, no prototype and no new. Named function expressions (const f = function fact(n) { ... fact(n - 1) }) help stack traces and recursion.
Q37. What are higher-order functions? [J]
Functions that take functions as arguments or return functions: map, filter, reduce, setTimeout, debounce, middleware. They are what makes composition, currying and memoization possible.
Q38. What is currying, and how is it different from partial application? [M]
Currying turns f(a, b, c) into f(a)(b)(c): a chain of one-argument functions. Partial application fixes some arguments and returns a function waiting for the rest: f.bind(null, a). In practice, “curry” helpers in JavaScript usually allow both styles, as in curry in src/functions.mjs. It relies on fn.length, which ignores rest parameters and parameters with defaults.
Q39. What is memoization and what are its pitfalls? [M]
Caching a function’s results by its arguments, so repeat calls are instant. Pitfalls: choosing the cache key (objects compare by reference, so JSON.stringify keys are slow and order-sensitive), unbounded memory growth (use an LRU or a WeakMap keyed by objects), and only memoizing pure functions. See memoize in src/functions.mjs and LRUCache in src/structures.mjs.
Q40. What is a pure function and why does it matter? [J]
Its output depends only on its inputs, and it has no side effects (no mutation of outside state, no I/O). Pure functions are easy to test, safe to memoize and safe to run in any order. React expects components to be pure during rendering. Methods like toSorted() (ES2023) exist so you can sort without mutating, which keeps functions pure.
Q41. What is the difference between debounce and throttle? [J]
- Debounce: wait until calls stop for
waitms, then run once. Use for search-as-you-type, auto-save, window-resize recalculation. - Throttle: run at most once per
waitms while calls keep coming. Use for scroll handlers, mouse-move tracking, rate-limited API calls.
Both are implemented with leading/trailing behavior and tests in src/functions.mjs. In interviews, mention cancellation and preserving this and arguments.
Q42. What are generators? [M]
A function* returns an iterator. Each yield pauses the function and hands out a value; next() resumes it. Generators produce values lazily, can be infinite, and power custom iterables.
function* ids() {
let id = 1;
while (true) yield id++;
}
const gen = ids();
gen.next().value; // 1
gen.next().value; // 2
Async generators (async function*) yield promises and are consumed with for await...of, which suits paginated APIs and streams.
7. Arrays, Maps, Sets and Iteration
Q43. map vs forEach vs for...of? [J]
map returns a new array of the same length. forEach returns undefined and is for side effects; you cannot break out of it, and it does not wait for async callbacks. for...of works on any iterable, supports break/continue, and works with await inside an async function. Use map to transform, for...of when you need control flow or sequential await.
Q44. for...in vs for...of? [J]
for...in loops over enumerable string keys, including inherited ones, which makes it a bad fit for arrays. for...of loops over the values of an iterable (arrays, strings, maps, sets, generators). For plain objects, use Object.keys, Object.values or Object.entries with for...of.
Q45. Which array methods mutate the original array? [J]
Mutating: push, pop, shift, unshift, splice, sort, reverse, fill, copyWithin. Non-mutating copies added in ES2023: toSorted, toReversed, toSpliced, with(index, value). A classic bug is arr.sort() inside a React render or a Redux reducer; use toSorted() instead.
Q46. Why does [10, 1, 3].sort() return [1, 10, 3]? [J]
Without a comparator, sort converts elements to strings and compares UTF-16 code units, so "10" comes before "3". Pass a comparator: arr.sort((a, b) => a - b). Since ES2019 the sort is required to be stable (equal elements keep their order).
Q47. Map vs plain object? Set vs array? [M]
Use a Map when keys are not strings (objects, numbers you do not want converted), when you add and delete often, when you need the size (map.size), or when keys come from users (no prototype keys like __proto__ or constructor to trip over). Plain objects fit fixed-shape records and JSON. Use a Set for uniqueness and fast has checks; [...new Set(arr)] de-duplicates an array. ES2025 added set operations: union, intersection, difference, symmetricDifference, isSubsetOf, isSupersetOf, isDisjointFrom.
Q48. What are WeakMap and WeakSet for? [S]
Their keys must be objects (or non-registered symbols), are held weakly, and are not enumerable. If nothing else references a key, it can be garbage collected along with its entry. Uses: attaching private data or cached metadata to objects you do not own (DOM nodes, third-party objects) without leaking memory. You cannot list their contents or get their size, by design.
Q49. What are iterator helpers? [M]
ES2025 added methods directly on iterators: map, filter, take, drop, flatMap, reduce, toArray, forEach, some, every, find, plus Iterator.from. ES2026 added Iterator.concat. They are lazy, so they work on infinite or huge sequences without building intermediate arrays:
function* naturals() { let n = 1; while (true) yield n++; }
naturals().filter((n) => n % 2).map((n) => n * n).take(3).toArray(); // [1, 9, 25]
Q50. How do you make an object iterable? [M]
Give it a [Symbol.iterator] method that returns an iterator (an object with next() returning { value, done }). A generator is the shortest way:
class Range {
constructor(from, to) { this.from = from; this.to = to; }
*[Symbol.iterator]() { for (let i = this.from; i <= this.to; i++) yield i; }
}
[...new Range(1, 3)]; // [1, 2, 3]
8. The Event Loop
Q51. Is JavaScript single-threaded? How does it do async work? [J]
Your JavaScript code runs on one thread with one call stack. Slow work (network, timers, file I/O) is handled by the host environment (the browser or Node’s libuv) outside that thread. When the work finishes, a callback is queued, and the event loop runs it once the call stack is empty. Real parallel JavaScript is possible with Web Workers or Node’s worker_threads, each with its own event loop and memory, talking through messages.
Q52. What are macrotasks and microtasks? [M]
- Tasks (macrotasks):
setTimeout,setInterval, I/O callbacks, UI events,MessageChannelmessages. - Microtasks: promise reactions (
then,catch,finally, code afterawait),queueMicrotask,MutationObservercallbacks.
The loop runs one task, then drains the entire microtask queue (including microtasks queued by microtasks), then the browser may render, then the next task. So promise callbacks always run before the next setTimeout callback, and an endless chain of microtasks can freeze the page.
Q53. In what order does this code log? [M]
The file src/event-loop-order.mjs contains:
console.log('1');
setTimeout(() => console.log('6'), 0);
Promise.resolve().then(() => console.log('4')).then(() => console.log('5'));
queueMicrotask(() => console.log('4b'));
(async () => {
console.log('2');
await null;
console.log('4c');
})();
console.log('3');
Output: 1, 2, 3, 4, 4b, 4c, 5, 6.
Why: synchronous code first (1, 2 because an async function runs synchronously until its first await, then 3). Then microtasks in the order they were queued: the first then (4), the queueMicrotask (4b), the continuation after await (4c). Running 4 queued the second then, so 5 comes next. The timeout is a task, so 6 is last. The test in test/polyfills-structures.test.mjs checks this exact order.
Q54. Does setTimeout(fn, 0) run immediately? [J]
No. It queues fn as a task after at least 0 ms, so it runs after the current code and all pending microtasks. Browsers clamp nested timeouts (after about 5 levels of nesting) to a minimum of around 4 ms, and background tabs throttle timers much more.
Q55. What is requestAnimationFrame and where does it fit? [M]
requestAnimationFrame(cb) runs cb right before the browser’s next repaint, typically 60 times per second or matched to the display’s refresh rate, and it pauses in background tabs. Use it for visual updates and animations instead of setTimeout, so updates line up with frames. It runs in the rendering step, after tasks and microtasks.
Q56. How do you keep a long computation from freezing the page? [S]
Split the work into chunks and yield to the event loop between them (await new Promise((r) => setTimeout(r)), or scheduler.yield() where supported), move it to a Web Worker, or make it smaller (pagination, virtualization, better algorithms). A long task over 50 ms delays input handling and hurts the Interaction to Next Paint (INP) metric.
9. Promises and Async/Await
Q57. What is a Promise? [J]
An object representing a value that will be available later. It starts pending and settles once, as fulfilled with a value or rejected with a reason. then registers callbacks and returns a new promise, which is what makes chaining work. Callbacks always run asynchronously, as microtasks, even if the promise is already settled.
Q58. Compare Promise.all, allSettled, race and any. [J]
| Method | Resolves when | Rejects when | Use for |
|---|---|---|---|
Promise.all |
All fulfill (array of values, input order) | Any one rejects (first reason) | Parallel requests that all must succeed |
Promise.allSettled |
All settle (array of {status, value/reason}) |
Never | Batch jobs where partial failure is OK |
Promise.race |
First to settle fulfills | First to settle rejects | Timeouts |
Promise.any |
First to fulfill | All reject (AggregateError) |
Fastest mirror or fallback sources |
All four are re-implemented with tests in src/promises.mjs. Note that Promise.all does not cancel the other operations when one fails; they keep running.
Q59. What is the difference between async/await and .then()? [J]
async/await is syntax over promises. An async function always returns a promise; await pauses the function (not the thread) until the promise settles, then resumes as a microtask. It reads like synchronous code and works with try/catch. .then() chains are still handy for small transformations and when you do not want to make a function async.
Q60. How do you handle errors with async/await? [J]
Wrap await calls in try/catch, or attach .catch() to the returned promise. An unhandled rejection triggers unhandledrejection in browsers and, by default, crashes Node.js (since Node 15). Common mistakes: forgetting await inside try, so the rejection escapes the catch; and return promise inside try without await, so the catch never sees the error.
async function load() {
try {
return await fetchJson('/api'); // `return await` here is needed for the catch to work
} catch (err) {
return { error: err.message };
}
}
Q61. Sequential vs parallel awaits: what is wrong with this? [M]
const user = await getUser(); // 300 ms
const posts = await getPosts(); // 300 ms, waits for getUser for no reason
The two requests are independent but run one after another (600 ms). Start both, then await together:
const [user, posts] = await Promise.all([getUser(), getPosts()]); // ~300 ms
The opposite mistake is array.forEach(async (x) => await save(x)), which fires everything at once and does not wait. Use for...of with await for sequential work, Promise.all for parallel work, or a concurrency limit (mapWithConcurrency in src/promises.mjs) when “all at once” would overload a server.
Q62. How do you add a timeout to a promise? How do you cancel a fetch? [M]
Race the promise against a timer and clear the timer afterwards (withTimeout in src/promises.mjs). Promises cannot be cancelled by themselves, so a timeout only stops you waiting. To actually stop a request, use AbortController: pass signal to fetch, and call controller.abort(). AbortSignal.timeout(ms) creates a signal that aborts on its own, and AbortSignal.any([...]) combines several.
const res = await fetch('/slow', { signal: AbortSignal.timeout(5000) });
Q63. What does Promise.withResolvers do? [M]
ES2024 added const { promise, resolve, reject } = Promise.withResolvers();. It replaces the old pattern of declaring let resolve outside the new Promise executor, which is useful when the code that settles the promise lives somewhere else (an event handler, a queue, a test helper).
Q64. How would you implement retry with exponential backoff? [M]
Loop, await the call, and on failure wait base * factor ** attempt before trying again, up to a limit. Production versions add jitter (randomize the delay so many clients do not retry in sync), retry only errors that are safe to retry (timeouts, 503, 429 with Retry-After), and never retry non-idempotent requests blindly. See retry in src/promises.mjs.
10. Modules
Q65. CommonJS vs ES modules? [M]
CommonJS (require) |
ES modules (import) |
|
|---|---|---|
| Loading | Synchronous, at runtime | Static structure, resolved before running; import() for dynamic |
| Exports | A copied value (module.exports) |
Live, read-only bindings |
Top-level await |
No | Yes |
| Tree-shaking | Hard | Easy, because imports are static |
| Where | Node.js (legacy default) | Browsers, Node.js, Deno, Bun |
New code should use ES modules. Recent Node.js versions can also require() an ES module that has no top-level await, which has made mixing the two much less painful.
Q66. What is tree-shaking? [M]
A bundler removes exports that nothing imports. It works because ES import/export statements are static and can be analyzed without running code. It breaks when modules have side effects at the top level, when code uses CommonJS, or when you import a whole namespace and access it dynamically. The "sideEffects": false field in package.json tells bundlers a package is safe to prune.
Q67. What does dynamic import() give you? [M]
import('./chart.js') returns a promise for the module. It enables code splitting (load heavy features only when needed), conditional loading, and loading ES modules from CommonJS. Bundlers turn each dynamic import into a separate chunk.
11. Errors and Debugging
Q68. What error types are built in? [J]
Error, TypeError (wrong type, e.g. calling undefined), ReferenceError (unknown variable or TDZ), SyntaxError, RangeError (invalid length, too much recursion), URIError, EvalError, and AggregateError (several errors at once, from Promise.any). ES2022 added cause: new Error('Save failed', { cause: err }) keeps the original error attached.
Q69. How do you create a custom error? [J]
class ValidationError extends Error {
constructor(field, message) {
super(message);
this.name = 'ValidationError';
this.field = field;
}
}
try { throw new ValidationError('email', 'Invalid email'); }
catch (e) { if (e instanceof ValidationError) console.log(e.field); }
instanceof fails across realms (iframes, workers, vm contexts). ES2026 added Error.isError(value), which recognizes genuine errors regardless of realm.
Q70. Does finally always run, and what if it returns? [M]
finally runs whether the try returned, threw, or the catch returned. If finally itself contains a return, that value replaces the earlier return or swallows the thrown error, which hides bugs. Keep finally for cleanup only.
Q71. How do you debug JavaScript effectively? [J]
Use the browser DevTools Sources panel or node --inspect: breakpoints, conditional breakpoints, logpoints, “pause on exceptions”, stepping, the call stack and scope panels. console.table for arrays of objects, console.trace for “who called this”, debugger; statements, and the Network and Performance panels for slow pages. Saying “I reproduce it, write a failing test, then bisect” is a good senior answer.
12. Memory and Performance
Q72. How does garbage collection work in JavaScript? [M]
Engines use reachability: anything reachable from the roots (globals, the current call stack, active closures) is kept; everything else can be collected. V8 uses a generational collector: most objects die young and are collected cheaply in the “young generation”, survivors move to the “old generation” which is collected less often with mark-and-sweep plus compaction. Reference cycles are not a problem for this kind of collector.
Q73. What causes memory leaks in JavaScript? [M]
- Event listeners never removed, especially on long-lived targets like
window. - Timers (
setInterval) that keep closures alive. - Unbounded caches and global arrays that only grow.
- Detached DOM nodes still referenced from JS.
- Closures capturing large objects longer than needed.
Find them with the DevTools Memory panel: take heap snapshots before and after repeating an action, and compare which objects grew.
Q74. What are WeakRef and FinalizationRegistry? [S]
WeakRef holds a reference that does not keep the object alive; deref() returns the object or undefined if it was collected. FinalizationRegistry runs a callback some time after an object is collected. Both are for advanced caches. GC timing is not guaranteed, so never use them for program logic that must run.
Q75. How do you make JavaScript code faster? [S]
Measure first (Performance panel, performance.now(), real-user metrics). Then: pick better algorithms and data structures (a Set lookup instead of array.includes in a loop), avoid layout thrashing in the browser (batch DOM reads, then writes), debounce or throttle frequent events, lazy-load code and data, move heavy work to workers, and keep object shapes consistent so the engine’s inline caches stay fast (initialize all fields in the constructor; do not delete properties on hot objects).
13. Modern JavaScript: ES2020 to ES2027
Q76. What has been added to JavaScript recently? [M]
Each June, Ecma approves a new edition containing the proposals that reached Stage 4. Highlights:
| Edition | Notable additions |
|---|---|
| ES2020 | ?., ??, BigInt, Promise.allSettled, globalThis, dynamic import(), String.prototype.matchAll |
| ES2021 | ??=, \|\|=, &&=, Promise.any, String.prototype.replaceAll, numeric separators (1_000_000), WeakRef |
| ES2022 | Class fields, private methods, static blocks, #x in obj, top-level await, .at(), Object.hasOwn, Error cause |
| ES2023 | findLast/findLastIndex, toSorted/toReversed/toSpliced/with, hashbang grammar, symbols as WeakMap keys |
| ES2024 | Object.groupBy/Map.groupBy, Promise.withResolvers, resizable ArrayBuffer, RegExp v flag, String.prototype.isWellFormed |
| ES2025 | Iterator helpers, new Set methods, Promise.try, RegExp.escape, JSON modules and import attributes, Float16Array, RegExp modifiers, duplicate named capture groups |
| ES2026 | Array.fromAsync, Error.isError, Math.sumPrecise, Uint8Array base64/hex methods, Iterator.concat, JSON.parse source text access, Map/WeakMap getOrInsert and getOrInsertComputed |
| ES2027 (Stage 4, not yet published) | Temporal, explicit resource management (using), Atomics.pause, iterator chunking and joint iteration |
The source of truth is TC39’s finished proposals list. Browsers and Node often ship features before the edition is published, and sometimes later, so check support per feature.
Q77. What is Temporal and why replace Date? [M]
Date is mutable, has 0-based months, only knows local time and UTC, and parses strings inconsistently. Temporal is a new global namespace with separate immutable types for different jobs: Temporal.Instant (an exact moment), Temporal.PlainDate (a calendar date with no time zone), Temporal.ZonedDateTime (a moment in a named time zone with correct DST math), Temporal.Duration, and more. It reached Stage 4 in 2026 and will be part of ES2027. Check MDN’s Temporal page for current runtime support, or use the polyfill until your targets ship it.
Q78. What does the using declaration do? [S]
Explicit resource management (Stage 4, ES2027) adds using and await using. When the block exits, normally or by an exception, the runtime calls the value’s [Symbol.dispose]() (or [Symbol.asyncDispose]()) method, in reverse order of declaration. It replaces try/finally cleanup for file handles, locks, database connections and subscriptions. DisposableStack groups several resources.
{
using lock = acquireLock(); // lock[Symbol.dispose]() runs when the block ends
doWork();
}
Q79. What is Map.prototype.getOrInsert? [M]
ES2026’s “upsert” proposal. map.getOrInsert(key, defaultValue) returns the existing value or inserts and returns the default. getOrInsertComputed(key, fn) only calls fn when the key is missing. It replaces the common pattern if (!map.has(k)) map.set(k, []); map.get(k).push(x) with map.getOrInsertComputed(k, () => []).push(x).
14. JavaScript in the Browser
Q80. What is event delegation? [J]
Attach one listener to a common ancestor instead of one per child, and use event.target.closest(selector) to find which child was clicked. It works because most events bubble. Benefits: fewer listeners, and it automatically covers children added later.
list.addEventListener('click', (e) => {
const item = e.target.closest('li[data-id]');
if (item && list.contains(item)) select(item.dataset.id);
});
Q81. Event bubbling vs capturing? stopPropagation vs preventDefault? [J]
An event travels down from window to the target (capture phase), then back up (bubble phase). Listeners run in the bubble phase unless you pass { capture: true }. stopPropagation() stops the event from reaching further elements. preventDefault() cancels the browser’s default action (following a link, submitting a form) but does not stop propagation.
Q82. What are defer, async and type="module" on script tags? [J]
- Plain
<script>: blocks HTML parsing while it downloads and runs. async: downloads in parallel, runs as soon as it arrives, in any order. Good for independent scripts like analytics.defer: downloads in parallel, runs after parsing finishes, in document order. Good for app code.type="module": deferred by default, strict mode, its own scope, supportsimport.
Q83. localStorage vs sessionStorage vs cookies vs IndexedDB? [J]
| Size (roughly) | Lifetime | Sent to server | API | |
|---|---|---|---|---|
| Cookies | About 4 KB each | Until expiry | Yes, on every matching request | String-based |
localStorage |
About 5 MB per origin | Until cleared | No | Synchronous strings |
sessionStorage |
About 5 MB per origin | Until the tab closes | No | Synchronous strings |
| IndexedDB | Large, quota-based | Until cleared | No | Asynchronous, structured data |
Never put auth tokens in localStorage if you can avoid it: any XSS can read it. HttpOnly, Secure, SameSite cookies are the usual choice for session IDs.
Q84. How do you prevent XSS in JavaScript code? [M]
Never insert untrusted strings as HTML. Use textContent instead of innerHTML, let your framework escape output, sanitize when you must render user HTML (a maintained sanitizer such as DOMPurify), avoid eval and new Function, and add a Content Security Policy. Trusted Types can enforce this in Chromium browsers.
15. Coding Round: Implement It Yourself
Each of these is a real file with tests. Try writing it yourself first, then compare.
| Exercise | File | What interviewers check |
|---|---|---|
Debounce (with leading option and cancel) |
src/functions.mjs |
Closures, timers, preserving this and arguments |
| Throttle (leading + trailing) | src/functions.mjs |
Timing logic, edge cases |
once, memoize, curry, compose, pipe |
src/functions.mjs |
Higher-order functions, fn.length |
Promise.all, allSettled, race, any |
src/promises.mjs |
Ordering, empty input, non-promise values |
withTimeout, retry, mapWithConcurrency |
src/promises.mjs |
Async control flow, cleanup |
Deep clone (cycles, Map, Set, Date) |
src/objects.mjs |
Recursion, WeakMap for cycles |
Deep equal, flatten, get, groupBy, chunk |
src/objects.mjs |
Recursion vs iteration, edge cases |
call, bind, map, filter, reduce, new, instanceof |
src/polyfills.mjs |
How the language works underneath |
Event emitter (on, off, once, emit) |
src/structures.mjs |
Data structures, removing during iteration |
| LRU cache in O(1) | src/structures.mjs |
Map insertion order |
Q85. Implement Promise.all. [M]
function promiseAll(iterable) {
return new Promise((resolve, reject) => {
const items = Array.from(iterable);
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; // index, not push: keep input order
if (--remaining === 0) resolve(results);
}, reject);
});
});
}
Points to say out loud: results keep input order even though promises finish in any order; an empty input resolves immediately; Promise.resolve(item) handles plain values and thenables; calling reject more than once is harmless because a promise settles only once.
Q86. Implement debounce. [M]
function debounce(fn, wait) {
let timer;
return function (...args) {
clearTimeout(timer);
timer = setTimeout(() => fn.apply(this, args), wait);
};
}
That is the 6-line version most interviewers expect first. Follow-ups: a leading option, a cancel method, a flush method, and a maxWait (which turns it into a hybrid with throttle). The full version is in src/functions.mjs.
Q87. Implement a deep clone. [M]
Handle primitives (return as is), use a WeakMap of already-copied objects so cycles and shared references survive, special-case Date, RegExp, Map and Set, and copy own keys including symbols with Reflect.ownKeys. Then mention that production code should use structuredClone. Full code: deepClone in src/objects.mjs.
Q88. Implement an LRU cache with O(1) get and set. [M]
In JavaScript a Map remembers insertion order, so “move to most recent” is delete + set, and the least recently used key is map.keys().next().value. In languages without an ordered map, the classic answer is a hash map plus a doubly linked list. See src/structures.mjs, and LeetCode 146: LRU Cache to practice.
Q89. Implement Function.prototype.bind. [S]
Return a function that calls the original with the fixed this and pre-filled arguments, concatenated with the new ones. The senior detail: if the bound function is called with new, the fixed this is ignored and a new instance of the original is constructed. See myBind in src/polyfills.mjs.
Q90. Run async tasks with a concurrency limit. [S]
Start limit workers. Each worker takes the next index from a shared counter, awaits the task, stores the result at that index, and repeats until the list is done. This keeps exactly limit tasks in flight with no queue bookkeeping. Discuss: what happens on failure (fail fast like Promise.all, or collect errors like allSettled), and cancellation with AbortSignal. See mapWithConcurrency in src/promises.mjs.
16. Output Prediction Questions
Answer each before opening the explanation.
1.
console.log(typeof typeof 1);
Answer
`"string"`. `typeof 1` is the string `"number"`, and `typeof "number"` is `"string"`.2.
const obj = {
name: 'obj',
regular() { return this.name; },
arrow: () => this?.name,
};
const { regular } = obj;
console.log(obj.regular(), obj.arrow(), regular());
Answer
In an ES module: `obj undefined` and then a `TypeError`. `obj.regular()` has `obj` before the dot. The arrow takes `this` from the module's top level, which is `undefined`, so `this?.name` is `undefined`. `regular()` is a plain call, so `this` is `undefined` in strict code and `this.name` throws. In a sloppy-mode script, `regular()` would read `window.name` instead (usually an empty string).3.
let a = 1;
{
console.log(a);
let a = 2;
}
Answer
`ReferenceError`. The inner `let a` is hoisted to the top of the block, so `console.log(a)` refers to the inner `a`, which is still in the temporal dead zone. It does not fall back to the outer `a`.4.
console.log([1, 2, 3].map(parseInt));
Answer
`[1, NaN, NaN]`. `map` passes `(value, index)`, so the calls are `parseInt(1, 0)` (radix 0 means "decide", gives 1), `parseInt(2, 1)` (radix 1 is invalid, `NaN`) and `parseInt(3, 2)` (3 is not a binary digit, `NaN`). Use `.map(Number)` or `.map((s) => parseInt(s, 10))`.5.
async function f() {
console.log('a');
await Promise.resolve();
console.log('b');
}
setTimeout(() => console.log('c'));
f();
Promise.resolve().then(() => console.log('d'));
console.log('e');
Answer
`a, e, b, d, c`. `a` and `e` are synchronous. The continuation after `await` was queued first (when `f()` ran), then the `then` callback, so `b` before `d`. The timeout is a task, so `c` is last.6.
const a = {};
const b = { key: 'b' };
const c = { key: 'c' };
a[b] = 123;
a[c] = 456;
console.log(a[b]);
Answer
`456`. Object keys are strings (or symbols), so both `b` and `c` become the key `"[object Object]"`. Use a `Map` for object keys.7.
for (var i = 0; i < 3; i++) setTimeout(() => console.log(i));
for (let j = 0; j < 3; j++) setTimeout(() => console.log(j));
Answer
`3, 3, 3, 0, 1, 2`. `var` shares one binding across iterations; `let` creates a new one each time.8.
console.log(0.1 + 0.2 === 0.3, [] == ![], NaN === NaN, [1] == 1);
Answer
`false true false true`. Float rounding; `![]` is `false`, then `[] == false` compares `0 == 0`; `NaN` never equals itself; `[1]` becomes `"1"` then `1`.9.
function Person(name) { this.name = name; }
Person.prototype.hi = function () { return 'hi ' + this.name; };
const p = new Person('Ana');
Person.prototype = { hi: () => 'replaced' };
console.log(p.hi(), new Person('Bo').hi());
Answer
`hi Ana replaced`. `p` keeps a link to the **old** prototype object. Re-assigning `Person.prototype` only affects objects created afterwards.10.
const p = Promise.reject(new Error('x'));
setTimeout(() => p.catch(() => console.log('caught')), 0);
Answer
In browsers, an `unhandledrejection` event (and a console error) fires, then `caught` is logged and a `rejectionhandled` event fires. In Node.js with the default `--unhandled-rejections=throw` mode, the process crashes before the timeout runs, because the rejection was unhandled when the microtask queue drained. Attach handlers before yielding to the event loop.Practice Problems on LeetCode
LeetCode’s free 30 Days of JavaScript study plan contains many problems in exactly this style. The ones below map to sections in this guide. Problems marked “Premium” need a paid LeetCode subscription.
Best Resources to Prepare
| Resource | Type | Cost | Best for |
|---|---|---|---|
| javascript.info | Online tutorial | Free | Best pick for learning or reviewing the whole language in order, with tasks after each chapter |
| MDN JavaScript Guide and Reference | Docs | Free | Exact behavior of any method or operator; browser compatibility tables |
| Eloquent JavaScript, 4th edition by Marijn Haverbeke | Book | Free online (print is paid) | A thorough, project-based book |
| You Don’t Know JS Yet by Kyle Simpson | Book series | Free on GitHub | Deep understanding of scope, closures, this and objects |
| ECMAScript specification | Spec | Free | Settling arguments; senior candidates who like precise answers |
| TC39 finished proposals | List | Free | What landed in which edition |
| Jake Archibald: Tasks, microtasks, queues and schedules | Article | Free | The clearest written explanation of microtask ordering |
| Philip Roberts: What the heck is the event loop anyway? | Talk | Free | Visual intro to the call stack and the event loop |
| Jake Archibald: In the Loop | Talk | Free | Event loop and rendering, requestAnimationFrame |
| web.dev Learn JavaScript | Course | Free | Short structured refresher from the Chrome team |
| MDN: JavaScript execution model | Docs | Free | Agents, realms, jobs and the event loop |
| Node.js test runner docs | Docs | Free | Writing tests like the ones in this repo, including mocked timers |
| LeetCode 30 Days of JavaScript | Practice | Free (some linked problems are Premium) | Daily coding drills in the interview format |
| BFE.dev | Practice | Free tier | Many “implement X” JavaScript and frontend questions |
| GreatFrontEnd | Practice | Free tier, most content paid | Frontend interview question bank with solutions |
If you pick only two: javascript.info to learn, and the src/ folder of this repo to practice writing the classic utilities from memory.
FAQ
What JavaScript questions are asked most often in interviews?
Closures, this, hoisting and let/const, == vs ===, prototypes, the event loop (microtasks vs macrotasks), promises and async/await, and at least one “implement it” task such as debounce, Promise.all or deep clone. Frontend roles add DOM events and browser storage; Node roles add modules and streams.
How should a junior prepare compared with a senior? Juniors should be able to explain each concept with a small example and write simple utilities. Seniors get the same topics but are expected to discuss trade-offs (performance, memory, error handling, cancellation), know modern APIs, and reason about real production bugs they have seen.
Do I need TypeScript for a JavaScript interview? Many teams use TypeScript, so expect questions on it for frontend and full-stack roles, but the core of the interview is still JavaScript semantics. TypeScript types are erased at runtime, so knowing JavaScript well makes TypeScript easier. The official TypeScript handbook is the best free starting point.
Is var still asked about?
Yes, mostly as a comparison with let/const and in output questions about loops and hoisting. You should not use it in new code.
Are output-prediction questions still common?
They are less common than a few years ago but still appear in screening rounds and online assessments, especially on the event loop, this and coercion. Section 16 covers the classic forms.
What is the best way to practice the coding round? Write each utility from an empty file with a timer, run the tests, then explain your code out loud as if to an interviewer. Repeat a week later. Speed comes from repetition, not from reading solutions.
Which ECMAScript version should I know?
Know ES2015 to ES2022 well (classes, modules, promises, async/await, optional chaining, class fields). Be aware of newer additions like toSorted, Object.groupBy, Set methods and iterator helpers. Mentioning Temporal or using correctly is a nice bonus, not a requirement.
Where to Go Next
- Frontend roles: the companion frontend-interview-questions covers HTML, CSS, browsers, performance and accessibility, and react-interview-questions covers React.
- Node.js roles: nodejs-interview-questions covers the Node event loop, streams and workers.
- Backend design rounds: backend-interview-questions.
- TypeScript: typescript-cheatsheet.
- Data structures and algorithms in JavaScript or TypeScript: leetcode-patterns.
Contributing
Pull requests are welcome: new questions, clearer answers, corrections when the language changes, and more tested exercises. Please:
- Keep answers short, accurate and in your own words. Explain the “why”, not only the “what”.
- Mark the level ([J], [M], [S]) and the ECMAScript edition for newer features.
- Put code exercises in
src/with a test intest/, and runnpm testbefore opening a PR. No dependencies. - Link to primary sources (MDN, the spec, TC39) when you state how something behaves.
License
The code in this repository is released under the MIT License.
If this helped you, a star helps others find it.
More free resources
Part of the Ralpberry Labs open-source collection. See also Top 100 Open Source.