Decorator Pattern in JavaScript
Wrapping a function or object to add extra behavior transparently, without modifying its original source code.
The Decorator pattern attaches additional behavior to an existing function or object dynamically, by wrapping it, without altering the original implementation's source code at all — the wrapped version presents (mostly) the same interface as the original but adds behavior before, after, or around the original call. In JavaScript, this pattern shows up constantly, both informally as simple higher-order 'wrapper' functions and formally through the newer, native @decorator syntax now standardized for classes.
The Decorator pattern is like a phone case: it wraps around the original phone, adding new capabilities (grip, protection, a kickstand) without opening up and modifying the phone's actual internal hardware — you can layer multiple cases/add-ons, and underneath it all, the original untouched phone is still doing exactly what it always did.