In this section, we'll consider some higher-order functions that provide a wrapper around other functions to enhance them in some way but without altering their original objective. In terms of design patterns (which we'll be revisiting in Chapter 11, Implementing Design Patterns – The Functional Way), we can also speak of decorators. This pattern is based on the concept of adding some behavior to an object (in our case, a function) without affecting other objects. The term decorator is also popular because of its usage in frameworks such as Angular or (in an experimental mode) for general programming in JavaScript.
Decorators are being considered for general adoption in JavaScript, but are currently (December 2019) still at Stage 2, Draft level, and it may be a while until they get to Stage 3 (Candidate) and finally...