⚡ Predict the Output

JavaScript Output Questions
What Does This Code Print?

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

Practice Free →Browse Questions ↓

⚡ How to use this page

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.

⚙️

Event Loop & Promises

22 questions

#01

Synchronous code runs before setTimeout

EasyEvent Loop & Promisesevent-loopsettimeout
▾
#02

Promise microtask before setTimeout macrotask

MediumEvent Loop & Promisesevent-looppromise
▾
#03

Promise chain passes values

MediumEvent Loop & Promisespromisechain
▾
#04

Two Promise chains interleave in microtask queue

HardEvent Loop & Promisespromisemicrotask
▾
#05

await suspends function — caller continues

MediumEvent Loop & Promisesasyncawait
▾
#06

setTimeout fires in delay order

MediumEvent Loop & Promisessettimeoutorder
▾
#07

Promise executor runs synchronously

MediumEvent Loop & Promisespromiseexecutor
▾
#08

Nested setTimeout creates new macrotask

HardEvent Loop & Promisessettimeoutnested
▾
#09

Promise.then is always async — even when resolved

MediumEvent Loop & Promisespromisemicrotask
▾
#10

async function always returns a Promise

MediumEvent Loop & Promisesasyncpromise
▾
#11

Multiple awaits — each is a microtask suspension

HardEvent Loop & Promisesasyncawait
▾
#12

Promise.reject caught by .catch — chain continues

MediumEvent Loop & Promisespromisecatch
▾
#13

Promise.all preserves order

MediumEvent Loop & Promisespromisepromise-all
▾
#14

queueMicrotask runs before setTimeout

MediumEvent Loop & PromisesqueueMicrotaskmicrotask
▾
#15

throw inside .then becomes rejection, caught by .catch

HardEvent Loop & Promisespromisethrow
▾
#16

async try/catch catches awaited rejection

HardEvent Loop & Promisesasynctry-catch
▾
#17

Deep Copy vs Shallow Copy in Promise Resolution

MediumEvent Loop & Promises
▾
#18

Understanding Call Stack Flow with Nested Function Calls

EasyEvent Loop & Promises
▾
#19

Deep Copy vs Shallow Copy with Promises

MediumEvent Loop & Promises
▾
#20

Deep Copy and Shallow Copy in Asynchronous Operations

MediumEvent Loop & Promises
▾
#21

Chaining Promises with Optional Chaining and Nullish Coalescing

HardEvent Loop & Promises
▾
#22

Resolving Nested Promises with Optional Chaining and Nullish Coalescing

HardEvent Loop & Promises
▾
🔒

Closures & Scope

13 questions

#23

Classic var in loop with setTimeout

EasyClosures & Scopeclosurevar
▾
#24

let in loop — each iteration gets own binding

EasyClosures & Scopeclosurelet
▾
#25

IIFE captures loop variable

MediumClosures & Scopeclosureiife
▾
#26

Closure mutation persists across calls

MediumClosures & Scopeclosuremutation
▾
#27

let block scope — inner does not leak

EasyClosures & Scopeletblock-scope
▾
#28

var leaks out of block, let does not

EasyClosures & Scopevarlet
▾
#29

Independent counter factory instances

MediumClosures & Scopeclosurefactory
▾
#30

Closure captures binding not snapshot

MediumClosures & Scopeclosurereference
▾
#31

var inside function shadows outer

MediumClosures & Scopevarhoisting
▾
#32

Curried closure

MediumClosures & Scopeclosurecurrying
▾
#33

Shared closure state across methods

HardClosures & Scopeclosureobject
▾
#34

for...in includes inherited properties, for...of does not

HardClosures & Scopefor-infor-of
▾
#35

Function is called with arguments object

HardClosures & Scopeargumentsrest
▾
👉

'this' Binding

10 questions

#36

Method call — this is the calling object

Easy'this' Bindingthismethod
▾
#37

Arrow function has no own this — inherits lexically

Easy'this' Bindingthisarrow
▾
#38

bind permanently fixes this — call cannot override it

Medium'this' Bindingthisbind
▾
#39

call vs apply — same result, different syntax

Medium'this' Bindingthiscall
▾
#40

Arrow callback inside method preserves this

Medium'this' Bindingthisarrow
▾
#41

Method chaining — return this

Medium'this' Bindingthischaining
▾
#42

this in nested object — direct parent wins

Medium'this' Bindingthisnested
▾
#43

bind with partial application

Hard'this' Bindingthisbind
▾
#44

Class method loses this when destructured

Hard'this' Bindingthisclass
▾
#45

new vs plain call — different returns

Hard'this' Bindingthisnew
▾
🚀

Hoisting

7 questions

#46

var declaration hoisted as undefined

EasyHoistinghoistingvar
▾
#47

Function declaration fully hoisted

EasyHoistinghoistingfunction-declaration
▾
#48

Function expression not hoisted

EasyHoistinghoistingfunction-expression
▾
#49

Local var shadows outer — from start of function

MediumHoistinghoistingvar
▾
#50

Function declaration takes priority over var in hoisting

MediumHoistinghoistingfunction-declaration
▾
#51

which function declaration wins?

MediumHoistinghoistingfunction-declaration
▾
#52

var escapes block, let does not

HardHoistinghoistingvar
▾
🔀

Type Coercion

15 questions

#53

Plus operator: string concat vs numeric add

EasyType Coercioncoercionplus
▾
#54

Loose equality edge cases with null

MediumType Coercioncoercionequality
▾
#55

typeof for common values

EasyType Coerciontypeofprimitives
▾
#56

Truthy and falsy — empty array and object are truthy

MediumType Coercionbooleantruthy
▾
#57

Unary plus converts to number

MediumType Coercioncoercionunary-plus
▾
#58

null comparison inconsistency

HardType Coercioncoercioncomparison
▾
#59

Short circuit: || vs ?? difference

EasyType Coercionshort-circuitor
▾
#60

Object valueOf for arithmetic, toString for template

HardType CoercioncoercionvalueOf
▾
#61

parseInt stops at first invalid character

MediumType CoercionparseIntradix
▾
#62

String comparison is lexicographic

MediumType Coercioncoercioncomparison
▾
#63

Array coercion with plus operator

HardType Coercioncoercionarray
▾
#64

NaN is not equal to anything including itself

EasyType Coercionnanequality
▾
#65

Object equality is reference-based

MediumType Coercionequalityreference
▾
#66

String spread — unicode-safe character split

MediumType Coercionspreadstring
▾
#67

JavaScript Optional Chaining and Nullish Coalescing

EasyType Coercion
▾
🔢

Array Methods

11 questions

#68

map transforms each element

EasyArray Methodsarraymap
▾
#69

filter then map chain

MediumArray Methodsarrayfilter
▾
#70

reduce accumulates to a single value

MediumArray Methodsarrayreduce
▾
#71

find returns first match; filter returns all

MediumArray Methodsarrayfind
▾
#72

reduce to build a frequency object

MediumArray Methodsarrayreduce
▾
#73

some and every — one fail vs all pass

EasyArray Methodsarraysome
▾
#74

flatMap — map then flatten one level

MediumArray MethodsarrayflatMap
▾
#75

Default sort is lexicographic — not numeric

MediumArray Methodsarraysort
▾
#76

Array destructuring with skip and rest

MediumArray Methodsarraydestructuring
▾
#77

Spread copy before sort preserves original

MediumArray Methodsarrayspread
▾
#78

reduce to group and aggregate

HardArray Methodsarrayreduce
▾
✨

Modern JS

15 questions

#79

Destructuring defaults apply only for undefined

EasyModern JSdestructuringdefault
▾
#80

Object spread — later properties win

EasyModern JSspreadobject
▾
#81

Optional chaining prevents TypeError on missing properties

MediumModern JSoptional-chainingnull
▾
#82

Nullish coalescing ?? vs OR ||

MediumModern JSnullish-coalescingor
▾
#83

Template literal expressions

EasyModern JStemplate-literalexpression
▾
#84

Computed property names with expressions

MediumModern JScomputed-propertyobject
▾
#85

Symbol keys hidden from Object.keys

MediumModern JSsymbolkey
▾
#86

Getter and setter intercept access

MediumModern JSgettersetter
▾
#87

Logical assignment operators

MediumModern JSlogical-assignment??=
▾
#88

Object.freeze prevents mutation silently

MediumModern JSObject.freezeimmutability
▾
#89

Map accepts any key type

MediumModern JSMapkey
▾
#90

Set deduplicates and preserves insertion order

EasyModern JSSetdedup
▾
#91

Promise.allSettled handles mixed results

HardModern JSpromiseallSettled
▾
#92

Proxy intercepts property access

MediumModern JSproxyget
▾
#93

Array.from with mapping function as range factory

MediumModern JSArray.fromlength
▾
🔄

Generators & Iterators

6 questions

#94

Generator pauses at yield, done true at end

MediumGenerators & Iteratorsgeneratoryield
▾
#95

return in generator — spread ignores return value

MediumGenerators & Iteratorsgeneratorreturn
▾
#96

yield* delegates to another iterable

MediumGenerators & Iteratorsgeneratoryield*
▾
#97

Generator as lazy range

EasyGenerators & Iteratorsgeneratorrange
▾
#98

Custom iterable with Symbol.iterator

MediumGenerators & IteratorsiteratorSymbol.iterator
▾
#99

next() argument becomes the value of the previous yield

HardGenerators & Iteratorsgeneratornext
▾
🧬

Prototypes & Inheritance

8 questions

#100

instanceof traverses the prototype chain

EasyPrototypes & Inheritanceinstanceofprototype
▾
#101

hasOwnProperty vs in operator

MediumPrototypes & InheritanceprototypehasOwnProperty
▾
#102

Class method override and instanceof

MediumPrototypes & Inheritanceclassextends
▾
#103

super calls the parent method

MediumPrototypes & Inheritanceclasssuper
▾
#104

Object.create sets prototype directly

MediumPrototypes & InheritanceprototypeObject.create
▾
#105

Own property shadows prototype property

MediumPrototypes & Inheritanceprototypeshadowing
▾
#106

Prototype changes visible to existing instances

HardPrototypes & Inheritanceprototypedynamic
▾
#107

Constructor property points back to the class

HardPrototypes & Inheritanceprototypeconstructor
▾
🔒

102 more questions with progress tracking

Free accounts get 5 tracked questions. Pro unlocks all 107+ output questions, debug lab, theory mastery, and the leaderboard.

⚡ Start Free — 5 QuestionsView Pro — $9.99/mo →

Related Resources