What are JavaScript design patterns?

Answer

Key JavaScript design patterns: Module pattern — encapsulates private state using closures: const counter = (() => { let n = 0; return { inc: () => ++n, get: () => n }; })(). Singleton — one instance: module-level variable or class with a static instance check. Observer/Pub-SubEventEmitter, custom event system, RxJS observables. Factory — creates objects without new: function createUser(type) { return type === "admin" ? new Admin() : new User(); }. Decorator — add behavior without subclassing: wrapping functions or using class decorators. Strategy — swap algorithms at runtime by passing functions. Prototype — clone objects instead of constructing from scratch: Object.create(proto). Command — encapsulate actions as objects (undo/redo). Facade — simple interface to complex subsystem. MixinObject.assign(Target.prototype, mixin). Modern JavaScript favors composition over inheritance and functional patterns over class hierarchies.