Created
April 8, 2023 08:27
-
-
Save Amitesh/ad7d75ec0a19be8f97c1beca87ed73b0 to your computer and use it in GitHub Desktop.
Revisions
-
Amitesh revised this gist
Apr 8, 2023 . No changes.There are no files selected for viewing
-
Amitesh created this gist
Apr 8, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ # Decorator in JavaScript and Typescript * In JavaScript, we can apply decorators to class fields, methods, and the entire class. Therefore, we can’t use decorators on plain objects. They only work with classes. * Decorators are not a standard JavaScript feature. They are in stage 3 of the ECMA TC39 specification phase. To use JavaScript Decorators we need to set up a transpiler tool in our development environment, like Babel. * Decorator is concept and can be in form of function or start with `@`. There are function decorator and class and it's member decorator. Fot indepenedent/global function we can decorate it by wrapping it inside another function but for class decorator we can use the `@` symbol and typescript or bable library. # References * https://medium.com/@victortoschi/using-decorators-in-javascript-e80674e4c6fa * https://www.sitepoint.com/javascript-decorators-what-they-are/ * https://www.typescriptlang.org/docs/handbook/decorators.html https://medium.com/codelit/functional-programming-in-javascript-decorators-43eef1c49cf3