TL;DR —
Early Exit From Functions is a good way to keep the code readable and maintainable. One of the easiest ways to increase readability is terminating early from methods/functions. The structure looks a lot simpler when we put the exits on top. If the exit logics are getting mixed and complicated that might be a good sign to split up the function to smaller functions. Exiting a function early almost always makes the function more readable. If we start writing a recursive function, we start with the exit logic.
[story continues]
Written by
@msarica
msarica.com
Topics and
tags
tags
typescript|javascript|programming|betterprogrammer|coding|experience|beginners|code-quality
This story on HackerNoon has a decentralized backup on Sia.
Transaction ID: ZUmmqng5GYVpDICtA_jLbkC6vadh9bnhhL22Fn85rWM
