ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant PDF download
Free updates forever

Prepare · Practice · Crack

JavaScript Coding Interview Questions

Short answer

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),[]);

This is 1 of 80+ questions in the JavaScript Interview Kit

Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.

⚡ Get the JavaScript Interview Kit → ₹299

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);}}

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.

This is 1 of 80+ questions in the JavaScript Interview Kit

Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.

⚡ Get the JavaScript Interview Kit → ₹299
Written by Arun Karthikeyan · Last updated

Full kit

JavaScript Interview Kit · ₹299

Get it →