Design Patterns · Junior · Question 9 of 75

What does the Decorator pattern do?

Explanation

The wrapper implements the same interface and adds logic before or after the call: caching, logging, retries. Examples: debounce(fn), withAuth(Component) (a HOC), @ decorators in TypeScript. Wrappers can be combined.

Further reading

Problem with a question

Design Patterns · Junior · question 9

Test yourself

Take the Design Patterns · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz