80%
JavaScript Scope, closures, this, prototypes, the event loop and async0/25 questions known
1. Types, equality and copying
DefinitionJavaScript is dynamically typed and single-threaded.
Primitives are copied by value; objects by reference.
Falsy values: false, 0, -0, 0n, "", null, undefined, NaN — everything else is truthy.
?? falls back only on null/undefined; || on any falsy value (so 0 || 5 is 5 but 0 ?? 5 is 0).
2. var, let, const and hoisting
var: function · yes, as undefined · yes
let: block · yes, but in the TDZ · yes
const: block · yes, but in the TDZ · no (objects stay mutable)
Common mistakeUsing a let/const before its line throws a ReferenceError (temporal dead zone).
3. Closures
DefinitionA closure is a function that remembers the variables of the scope it was created in, even after that scope has returned.
4. this, call, apply and bind
obj.method(): obj
fn() (strict mode): undefined
new Fn(): the new object
fn.call(x) / apply(x) / bind(x): x
5. Prototypes and classes
Every object has a hidden link ([[Prototype]]) to another object.
6. The event loop
FlowAfter each task, ALL microtasks run before the next macrotaskCall stack (sync code)→Microtasks (promises)→Render→One macrotask (timers, I/O)→repeat
TipInterview answer: "sync first, then all microtasks, then one macrotask".
7. Promises and async/await
Promise.all: all succeed (rejects on the first failure)
Promise.allSettled: all finish, success or failure
Promise.race: the first one settles
Promise.any: the first one succeeds
Common mistakeawait inside forEach does not wait — use for…of (sequential) or Promise.all(arr.map(…)) (parallel).
8. Must-know utilities: debounce, throttle, array methods
Debounce: run after calls stop (search box).
map/filter/slice/toSorted return new arrays; sort/splice/push/reverse mutate.
ES modules: import/export, statically analysed (tree-shaking); CommonJS: require/module.exports, loaded at runtime.
Reviselet/const + TDZ, closures, this depends on the call site, prototype chain, sync → microtasks → macrotask, Promise.all for parallel work, debounce vs…
Most asked (11)
QWhat is the difference between var, let and const?Scope: var is function-scoped; let and const are block-scoped (inside {}).
QWhat is a closure? Give a real use.A closure is a function bundled with the variables of the scope where it was created.
QExplain the event loop. What prints first: a setTimeout(…, 0) or a resolved promise?JavaScript runs on one thread with a call stack.
QHow is this decided in JavaScript?this depends on how a function is called, not where it is written: - obj.method(): this is obj - a plain call fn(): undefined in strict…
Q== vs ===?=== (strict equality) compares value and type with no conversion.
QWhat is hoisting?Before code runs, the engine sets up each scope.
QWhat are promises, and how does async/await relate to them?A promise stands for a value that will be ready later.
QDebounce vs throttle. Implement debounce.- Debounce: run only after the calls have stopped for ms (search box, window resize end) - Throttle: run at most once every ms while the…
QShallow copy vs deep copy? How do you deep-copy an object?A shallow copy ({...obj}, Object.assign, arr.slice()) copies only the top level.
QHow are arrow functions different from regular functions?- no own this: they use this from the surrounding scope, which is great for callbacks - no arguments object; use rest parameters - cannot…
QOutput question: what does this print, and why?This is a classic mix of hoisting, the event loop and loop scope: 1.