Meta-programming with ES2016 decorators

JavaScript is a dynamic language that allows us to easily modify and/or alter the behavior to suit the programs we write. Decorators are a proposal to ES2016, which according to the design document https://github.com/wycats/javascript-decorators:

"...make it possible to annotate and modify classes and properties at design time."

Their syntaxes are quite similar to the annotations in Java, and they are even closer to the decorators in Python. ES2016 decorators are used commonly in Angular to define components, directives, and pipes, and to take advantage of the dependency injection mechanism of the framework. Most use cases of decorators involve altering the behavior to a predefined logic or adding some metadata ...

Get Getting Started with Angular - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.