JavaScript Input & Output Interview Handbook

🎨 Q&A48 topics · 555 cards · ~45 min
0/2
0%
  1. Cover the answer. Read only the Question block, write your predicted output on paper.
  2. Reveal and compare. Read the Answer, then the Step-by-Step Execution.
  3. Internalize the mechanism. The Why? section is where the real learning is — it maps output back to the engine (execution context, event loop, prototype chain, etc.).
  4. Rehearse out loud. In interviews you must narrate the reasoning, not just state the answer.

> Note on scope: This is a curated, high-signal set of ~45 questions spanning every topic in the syllabus below. It is designed to be extended — each section can hold many more questions in the identical format. If you want additional batches for any single topic (e.g., "100 more Promise questions"), request that topic and I'll append them.

---

  • [1. Variables, Hoisting & TDZ](#1-variables-hoisting--tdz)

- [Q1 — var hoisting returns undefined](#q1)
- [Q2 — Temporal Dead Zone with let](#q2)
- [Q3 — Function declaration vs expression hoisting](#q3)
- [Q4 — Variable shadowing in blocks](#q4)

  • [2. Closures](#2-closures)

- [Q5 — Loop closure: var vs let with setTimeout](#q5)
- [Q6 — Counter factory (private state)](#q6)
- [Q7 — Closure capturing a shared reference](#q7)

  • [3. The this Keyword](#3-the-this-keyword)

- [Q8 — Method vs arrow function this](#q8)
- [Q9 — Losing this on detached method](#q9)
- [Q10 — call, apply, bind](#q10)
- [Q11 — this inside setTimeout](#q11)

  • [4. Prototypes & Inheritance](#4-prototypes--inheritance)

- [Q12 — Prototype chain lookup](#q12)
- [Q13 — prototype vs __proto__](#q13)
- [Q14 — Shadowing a prototype method](#q14)

  • [5. Objects](#5-objects)

- [Q15 — Reference vs value assignment](#q15)
- [Q16 — Object.freeze is shallow](#q16)
- [Q17 — Object key coercion](#q17)
- [Q18 — Spread makes a shallow copy](#q18)

  • [6. Arrays](#6-arrays)

- [Q19 — map(parseInt) classic trap](#q19)
- [Q20 — Default sort is lexicographic](#q20)
- [Q21 — reduce without initial value](#q21)
- [Q22 — Sparse arrays and forEach](#q22)

  • [7. Functions](#7-functions)

- [Q23 — Currying](#q23)
- [Q24 — IIFE and hoisting](#q24)
- [Q25 — Default parameters evaluated at call time](#q25)

  • [8. Async JavaScript & Event Loop](#8-async-javascript--event-loop)

- [Q26 — setTimeout vs Promise ordering](#q26)
- [Q27 — async/await interleaving](#q27)
- [Q28 — Promise chain return values](#q28)
- [Q29 — Promise.all vs Promise.race vs allSettled](#q29)
- [Q30 — throw inside async function](#q30)
- [Q31 — Nested microtasks vs macrotasks](#q31)

  • [9. Type Coercion & Operators](#9-type-coercion--operators)

- [Q32 — The + operator and coercion](#q32)
- [Q33 — == vs === and the coercion table](#q33)
- [Q34 — NaN and comparisons](#q34)
- [Q35 — Array to primitive coercion](#q35)

  • [10. Numbers & BigInt](#10-numbers--bigint)

- [Q36 — 0.1 + 0.2 floating point](#q36)
- [Q37 — BigInt vs Number](#q37)

  • [11. Generators & Iterators](#11-generators--iterators)

- [Q38 — Generator lazy evaluation](#q38)
- [Q39 — Custom Symbol.iterator](#q39)

  • [12. Classes](#12-classes)

- [Q40 — super and constructor order](#q40)
- [Q41 — Static vs instance fields](#q41)

  • [13. Errors](#13-errors)

- [Q42 — try/catch/finally with return](#q42)

  • [14. Advanced (Proxy / Symbol / WeakMap)](#14-advanced-proxy--symbol--weakmap)

- [Q43 — Proxy get trap](#q43)
- [Q44 — Symbol uniqueness](#q44)

  • [15. Polyfill & Implementation Questions](#15-polyfill--implementation-questions)

- [Q45 — Implement Function.prototype.bind](#q45)

  • [Appendix A — Event Loop Mental Model](#appendix-a--event-loop-mental-model)
  • [Appendix B — Coercion Cheat Sheet](#appendix-b--coercion-cheat-sheet)
  • [Appendix C — Interview Strategy](#appendix-c--interview-strategy)

---