Loading...
Loading...
Browse 4 real-world technical and behavioral interview questions about Javascript. Review scenarios, edge cases, and architectural best practices.
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.
JavaScript `this` binding is decided by the call site: method calls bind the receiver, constructors bind the new object, bind/call/apply bind explicitly, and callbacks often lose the receiver because the method was passed as a plain function. It also connects arrow functions to the point an interviewer is testing.
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.
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.