Episode 1 — Fundamentals / 1.17 — Additional JavaScript Topics

1.17 — Additional Topics: Quick Revision

Episode 1 supplement — print-friendly.

How to use

Skim → drill weak spots in 1.17.a / 1.17.b1.17-Exercise-Questions.md.


Throttle vs debounce

ThrottleDebounce
IdeaMax 1 call per wait ms while firingRun after delay ms quiet`
ExamplesScroll spy, sampled metricsSearch-as-you-type, resize-end layout
TimerLast-run timestamp (typical)setTimeout reset each call

Scroll performance: combine with { passive: true } when not calling preventDefault.

Visual sync: consider requestAnimationFrame.


JSON (Episode 1 scope)

JSON.stringify({ a: 1 });           // '{"a":1}'
JSON.parse('{"a":1}');              // { a: 1 }

localStorage.setItem("k", JSON.stringify(obj));
JSON.parse(localStorage.getItem("k") ?? "{}");
APIRole
JSON.stringify(value)Value → string (throws on cycle)
JSON.parse(text)Valid JSON string → value (SyntaxError if bad)
response.json()fetch helper — parse body as JSON

Not in JSON: functions, undefined (dropped in objects), Symbol keys, arbitrary class types (plain objects round-trip).


One-liners

  • Throttle = cap frequency.
  • Debounce = wait for silence.
  • parse/stringify = bridge objectstext for HTTP and storage.

End of 1.17 quick revision.