6. Accessor Decorator
# Typescript Decorator
Medium
Accessor is actually just a method with the prefix "get" or "set", used to get and set some properties in a way that calls the property. The usage of decorators is no different from regular methods, except that when getting the value, it calls the "get" and "set" of the descriptor to replace the value. For example, if we add a field "nickname", we can add a custom prefix to set "nickname" and prevent the value of "nickname" from appearing when iterating through the "user" object. We can also add a field "fullname" and generate a string suffix when setting "nickname".