ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant Drive delivery
Free updates forever

Prepare · Practice · Crack

JavaScript Coding Interview Questions

Frontend rounds ask you to implement small utilities live. Here are the classics with the approach and a solution.

Implement debounce

Return a function that clears a timer on every call and only runs fn once calls stop for `delay` ms.

function debounce(fn, delay=300){
  let t; return function(...a){ clearTimeout(t); t=setTimeout(()=>fn.apply(this,a),delay); };
}

Implement throttle

Run fn at most once per interval by tracking the last-run timestamp in a closure.

Flatten a nested array

Reduce, recursing into arrays — or use arr.flat(Infinity).

const flatten = a => a.reduce((o,x)=>o.concat(Array.isArray(x)?flatten(x):x),[]);

Deep clone an object

Recurse: primitives return as-is, arrays map a recursive clone, objects rebuild key by key — or use structuredClone(obj) for a faithful copy.

Implement Promise.all

Return a promise that resolves to an ordered results array when all inputs fulfil, storing each value at its index and counting completions; reject on the first failure.

Two Sum

One pass with a hash map: for each number, check if (target − number) was already seen. O(n).

function twoSum(n,t){const m=new Map();for(let i=0;i<n.length;i++){if(m.has(t-n[i]))return[m.get(t-n[i]),i];m.set(n[i],i);}}

Every must-implement utility, solved

Patterns, polyfills, async problems and DSA-lite — with clean solutions in the JavaScript Coding Handbook.

⚡ Get the JavaScript Interview Kit → ₹299

Frequently asked questions

What coding questions are most common in frontend?
debounce, throttle, curry, memoize, deep clone, flatten, Promise.all polyfill, and array problems like Two Sum and Kadane's.
How should I approach a coding question?
Clarify the input, state your approach and complexity, code the happy path, then handle edge cases — think out loud throughout.

Full kit

JavaScript Interview Kit · ₹299

Get it →