call(back)

JavaScript Coding Interviews

The JavaScript round in the order the topics build: how to run it, closures and this, the array polyfills, timers and promises, the lodash classics, a data-selection question, then the DOM — with the one bug each is known for.

1

How Do You Approach a JavaScript Coding Question?

Frontend · Clarify the runtime and the edges, say which spec cases you are skipping, then dodge the one bug each classic is known for.

mediumSign in to star problems
2

What Is a Closure?

Frontend · A function plus the bindings of the scope it was created in — bindings, not snapshots.

easySign in to star problems
3

Predict the Output: var and let in a Loop With Timers

Frontend · var gives the loop one shared binding; let gives each iteration its own.

easySign in to star problems
4

Implement Function.prototype.bind

Frontend · A closure over thisArg and the leading arguments; the original runs later, with the call's own arguments appended.

easySign in to star problems
5

Implement Array.prototype.map

Frontend · Pre-size the output so holes stay holes, and forward thisArg.

easySign in to star problems
6

Implement Array.prototype.filter

Frontend · Skip holes, forward thisArg, and keep the elements whose callback is truthy.

easySign in to star problems
7

Implement Array.prototype.reduce

Frontend · A missing initial value versus an undefined one — and the TypeError when there's nothing to reduce.

mediumSign in to star problems
8

Predict the Output: Promise and Timer Order

Frontend · A promise resolved inside a timer, two more timers, and a microtask: the event loop decides the order.

mediumSign in to star problems
9

Implement a Promise

Frontend · A one-way state machine, a handler queue, and every callback in a microtask.

hardSign in to star problems
10

Debounce

Frontend · Closures and timers, the frontend screen classic.

easySign in to star problems
11

Implement Throttle

Frontend · A leading call, then at most one call per window — with a trailing call that carries the latest arguments.

mediumSign in to star problems
12

Implement Promise.all

Frontend · Store results by index, count down, resolve an empty input at once, reject on the first failure.

mediumSign in to star problems
13

Implement Promise.allSettled

Frontend · Record every outcome by index as { status, value | reason }; it never rejects, and an empty input resolves at once.

mediumSign in to star problems
14

Implement Promise.any

Frontend · Resolve on the first fulfilment; reject only when every input has failed, with an AggregateError whose errors follow input order.

mediumSign in to star problems
15

Retry With Exponential Backoff

Frontend · Try, wait, multiply the wait, try again: the first fulfilment wins, the last failure is the error, and no wait follows it.

mediumSign in to star problems
16

Implement curry

Frontend · Collect arguments until fn.length have arrived — with a fresh array per call so partials stay independent.

mediumSign in to star problems
17

Implement Array.prototype.flat

Frontend · Depth, holes and Infinity — without recursion, so 100,000 levels can't overflow the stack.

mediumSign in to star problems
18

Implement cloneDeep

Frontend · Cycles, shared references, Date, RegExp, Map, Set, prototypes and symbol keys: everything spread and JSON get wrong.

mediumSign in to star problems
19

Implement classNames

Frontend · Strings and numbers pass through, objects add their truthy keys, arrays recurse, falsy values vanish, one space between.

easySign in to star problems
20

Implement an Event Emitter

Frontend · A map from event name to listener list; copy the list before emitting so listeners can unsubscribe mid-emit.

mediumSign in to star problems
21

Implement memoize

Frontend · A closure over a Map keyed on every argument — and has, not truthiness, so 0 and undefined still hit.

mediumSign in to star problems
22

Implement JSON.stringify

Frontend · A recursive serializer with the real rules: undefined vanishes from objects but becomes null in arrays, and strings need escaping.

mediumSign in to star problems
23

Data Selection

Frontend · Merge per user with a Map re-inserted on every session so order follows the last one, then filter the merged rows.

hardSign in to star problems
24

Implement getElementsByTagName

Frontend · A depth-first walk over children comparing upper-cased tag names: document order for free, text nodes never seen.

mediumSign in to star problems
25

A Tooltip Library From data Attributes

Frontend · One tooltip node, delegated listeners, keyboard focus and Escape — in plain DOM, not a component.

mediumSign in to star problems