- Expert Angular
- Mathieu Nayrolles Rajesh Gunasundaram Sridhar Rao
- 103字
- 2021-07-15 17:05:34
Decorators
Decorators enable us to extend a class or object by adding behaviors without modifying code. Decorators wrap the class with extra functionality. Decorators can be attached to a class, property, method, parameter, and accessor. In ECMAScript 2016, decorators are proposed to modify the behavior of a class. Decorators are prefixed with the @ symbol and a decorator name that resolves to a function called at runtime.
The following code snippet shows the authorize function, and it can be used as the @authorize decorator on any other class:
function authorize(target) { // check the authorization of the use to access the "target" }
推薦閱讀
- Advanced Splunk
- Python科學計算(第2版)
- Visual Studio 2012 Cookbook
- Linux C/C++服務器開發實踐
- Scala Design Patterns
- 看透JavaScript:原理、方法與實踐
- Python高級編程
- Big Data Analytics
- Expert Data Visualization
- Oracle Exadata專家手冊
- Learning Hunk
- Building Serverless Architectures
- 編程改變生活:用Python提升你的能力(進階篇·微課視頻版)
- C++程序設計教程
- jQuery Mobile Web Development Essentials(Second Edition)