Strategy Pattern
Encapsulating interchangeable algorithms or behaviors behind a common interface so they can be swapped at runtime without changing the code that uses them.
The Strategy pattern defines a family of interchangeable algorithms or behaviors, encapsulates each one separately behind a common interface, and lets the calling code select and swap between them at runtime, rather than hardcoding a single fixed algorithm or scattering conditional branches (if/else or switch chains) throughout the consuming code every time a variant is needed. It's a very natural fit for JavaScript specifically, since functions are first-class values, so 'a strategy' is often literally just a plain function passed around, without needing the more ceremonial interface/class-based structure the pattern requires in stricter, more rigid OOP languages.
The Strategy pattern is like a GPS navigation app offering several route-calculation modes — fastest, shortest, avoid tolls — where the app's core turn-by-turn guidance logic doesn't care which specific mode you picked, it just plugs whichever route-calculation strategy you selected into the same guidance system, and adding a brand-new 'scenic route' mode later doesn't require touching the guidance engine itself at all.