Synchronous code runs before setTimeout
107+ real JavaScript output prediction questions from frontend interviews. Read code → predict console.log → learn why.
✅ 107 questions · ✅ First 5 interactive free · ✅ Progress saved in quiz
Try the first 5 questions here — click a question, type your prediction, check it. No account needed. The rest are in the interactive quiz where progress is tracked. Reading answers ≠ predicting them.
22 questions
Synchronous code runs before setTimeout
Promise microtask before setTimeout macrotask
Promise chain passes values
Two Promise chains interleave in microtask queue
await suspends function — caller continues
setTimeout fires in delay order
Promise executor runs synchronously
Nested setTimeout creates new macrotask
Promise.then is always async — even when resolved
async function always returns a Promise
Multiple awaits — each is a microtask suspension
Promise.reject caught by .catch — chain continues
Promise.all preserves order
queueMicrotask runs before setTimeout
throw inside .then becomes rejection, caught by .catch
async try/catch catches awaited rejection
Deep Copy vs Shallow Copy in Promise Resolution
Understanding Call Stack Flow with Nested Function Calls
Deep Copy vs Shallow Copy with Promises
Deep Copy and Shallow Copy in Asynchronous Operations
Chaining Promises with Optional Chaining and Nullish Coalescing
Resolving Nested Promises with Optional Chaining and Nullish Coalescing
13 questions
Classic var in loop with setTimeout
let in loop — each iteration gets own binding
IIFE captures loop variable
Closure mutation persists across calls
let block scope — inner does not leak
var leaks out of block, let does not
Independent counter factory instances
Closure captures binding not snapshot
var inside function shadows outer
Curried closure
Shared closure state across methods
for...in includes inherited properties, for...of does not
Function is called with arguments object
10 questions
Method call — this is the calling object
Arrow function has no own this — inherits lexically
bind permanently fixes this — call cannot override it
call vs apply — same result, different syntax
Arrow callback inside method preserves this
Method chaining — return this
this in nested object — direct parent wins
bind with partial application
Class method loses this when destructured
new vs plain call — different returns
7 questions
var declaration hoisted as undefined
Function declaration fully hoisted
Function expression not hoisted
Local var shadows outer — from start of function
Function declaration takes priority over var in hoisting
which function declaration wins?
var escapes block, let does not
15 questions
Plus operator: string concat vs numeric add
Loose equality edge cases with null
typeof for common values
Truthy and falsy — empty array and object are truthy
Unary plus converts to number
null comparison inconsistency
Short circuit: || vs ?? difference
Object valueOf for arithmetic, toString for template
parseInt stops at first invalid character
String comparison is lexicographic
Array coercion with plus operator
NaN is not equal to anything including itself
Object equality is reference-based
String spread — unicode-safe character split
JavaScript Optional Chaining and Nullish Coalescing
11 questions
map transforms each element
filter then map chain
reduce accumulates to a single value
find returns first match; filter returns all
reduce to build a frequency object
some and every — one fail vs all pass
flatMap — map then flatten one level
Default sort is lexicographic — not numeric
Array destructuring with skip and rest
Spread copy before sort preserves original
reduce to group and aggregate
15 questions
Destructuring defaults apply only for undefined
Object spread — later properties win
Optional chaining prevents TypeError on missing properties
Nullish coalescing ?? vs OR ||
Template literal expressions
Computed property names with expressions
Symbol keys hidden from Object.keys
Getter and setter intercept access
Logical assignment operators
Object.freeze prevents mutation silently
Map accepts any key type
Set deduplicates and preserves insertion order
Promise.allSettled handles mixed results
Proxy intercepts property access
Array.from with mapping function as range factory
6 questions
Generator pauses at yield, done true at end
return in generator — spread ignores return value
yield* delegates to another iterable
Generator as lazy range
Custom iterable with Symbol.iterator
next() argument becomes the value of the previous yield
8 questions
instanceof traverses the prototype chain
hasOwnProperty vs in operator
Class method override and instanceof
super calls the parent method
Object.create sets prototype directly
Own property shadows prototype property
Prototype changes visible to existing instances
Constructor property points back to the class
Free accounts get 5 tracked questions. Pro unlocks all 107+ output questions, debug lab, theory mastery, and the leaderboard.