Skip to content
Preptima

JavaScript Core interview questions

Closures, the event loop, prototypes, coercion, and the async semantics in every frontend screen.

4 questions in Frontend Engineering.

medium4

mediumConceptScenario

A save button calls an API, the request fails, the error appears in the console - and the UI still shows 'Saved'. Walk me through what is actually happening in that promise chain.

A catch handler that returns normally converts a rejected promise into a fulfilled one, so every then after it runs as though nothing failed. Combined with fetch, which only rejects on network errors and resolves happily on a 500, the chain reports success twice over. Fix by re-throwing from catch, checking response.ok, and modelling UI state as a machine.

4 minentry, mid, senior
mediumCodingConcept

Here is a script mixing setTimeout, a promise chain and an await. Tell me the order the logs come out in, and why.

The engine finishes the current task, then drains the whole microtask queue before taking another task, so every promise callback and await resumption runs before a zero-delay timeout, in the order each was queued. Use this event loop answer to show the decision, trade-off, and evidence rather than a memorised definition. It also connects microtasks to the point an interviewer is testing.

4 minmid, senior
mediumConceptCoding

What is a closure, and how does one end up leaking memory?

A closure is a function plus the scope it was created in, held by reference rather than copied. It leaks when something long-lived keeps the function alive, because everything the captured scope can reach stays reachable with it.

4 minentry, mid, senior