DEV Community

Discussion on: Refactoring: My 6 favorite patterns

Collapse
 
llcamara profile image
LLCamara

For #3, my usual suggestion for refactoring is to create a function instead of a const variable - in this case user.isSubscribed().

The nice thing I see in having a const variable is when there is a complex calculation used multiple times. Then sure, do the calculation once, store in a const and fire away.