Skip to main content

48–50 · Programming Paradigms & Patterns

Use the numbered sections as the learning path. Each section keeps the language/host boundary explicit and links syntax to runtime behavior, production concerns, and interview reasoning.

48 · Functional Programming in JavaScript​

Language lens: default authority is ECMA-262; runtime/browser support notes are implementation questions, not changes to semantics.

Functional JavaScript treats functions and immutable transformations as primary composition tools. Purity and referential transparency are useful design properties, not requirements of the language; side effects still exist at system boundaries.

Mental model / runnable experiment​

// 48: Functional Programming in JavaScript
// Build a tiny experiment, state the expected observable behavior,
// then verify it in every runtime you target rather than relying on folklore.

Coverage contract​

  • first-class functions
  • higher-order functions
  • closures
  • pure functions
  • immutability
  • composition
  • currying
  • partial application
  • map/filter/reduce
  • declarative transformations
  • referential transparency concepts
  • trade-offs

Common mistakes / edge cases​

  • Separate syntax and ECMAScript semantics from host APIs and engine implementation details.
  • Trace evaluation order, conversions, ownership, cleanup, and failure behavior instead of memorizing slogans.
  • Check recently standardized APIs against the runtimes/browsers you actually support.

Production and senior reasoning​

State what is guaranteed by the language, what the host decides, and what is merely an engine strategy. At boundaries, define validation, cancellation, error, mutation, compatibility, performance, and security contracts explicitly.

Interview drill: explain Functional Programming in JavaScript from first principles, predict one edge case, and describe how you would prove the behavior with a minimal experiment.

49 · Object-Oriented JavaScript​

Language lens: default authority is ECMA-262; runtime/browser support notes are implementation questions, not changes to semantics.

Object-oriented JavaScript is prototype-based. Encapsulation can use closures or private fields, polymorphism can rely on shared protocols, and composition often reduces inheritance coupling.

Mental model / runnable experiment​

// 49: Object-Oriented JavaScript
// Build a tiny experiment, state the expected observable behavior,
// then verify it in every runtime you target rather than relying on folklore.

Coverage contract​

  • encapsulation
  • composition
  • inheritance
  • prototypes
  • classes
  • private fields
  • delegation
  • polymorphism
  • composition over inheritance
  • object capability thinking

Common mistakes / edge cases​

  • Separate syntax and ECMAScript semantics from host APIs and engine implementation details.
  • Trace evaluation order, conversions, ownership, cleanup, and failure behavior instead of memorizing slogans.
  • Check recently standardized APIs against the runtimes/browsers you actually support.

Production and senior reasoning​

State what is guaranteed by the language, what the host decides, and what is merely an engine strategy. At boundaries, define validation, cancellation, error, mutation, compatibility, performance, and security contracts explicitly.

Interview drill: explain Object-Oriented JavaScript from first principles, predict one edge case, and describe how you would prove the behavior with a minimal experiment.

50 · JavaScript Design Patterns​

Language lens: default authority is ECMA-262; runtime/browser support notes are implementation questions, not changes to semantics.

Patterns are reusable trade-off shapes, not goals. JavaScript's first-class functions, modules, objects, closures, and event systems often make classic patterns lighter than their class-heavy textbook forms.

Mental model / runnable experiment​

// 50: JavaScript Design Patterns
// Build a tiny experiment, state the expected observable behavior,
// then verify it in every runtime you target rather than relying on folklore.

Coverage contract​

  • module
  • factory
  • builder
  • strategy
  • observer
  • pub/sub
  • adapter
  • facade
  • decorator pattern
  • command
  • state
  • dependency injection
  • middleware
  • plugin architecture

Common mistakes / edge cases​

  • Separate syntax and ECMAScript semantics from host APIs and engine implementation details.
  • Trace evaluation order, conversions, ownership, cleanup, and failure behavior instead of memorizing slogans.
  • Check recently standardized APIs against the runtimes/browsers you actually support.

Production and senior reasoning​

State what is guaranteed by the language, what the host decides, and what is merely an engine strategy. At boundaries, define validation, cancellation, error, mutation, compatibility, performance, and security contracts explicitly.

Interview drill: explain JavaScript Design Patterns from first principles, predict one edge case, and describe how you would prove the behavior with a minimal experiment.