DEV Community

Discussion on: If/else or just if?

Collapse
 
fhusquinet profile image
Florian Husquinet

I find it more confusing to return a variable in a return unless it is really basic (like changing the message of a JSON response depending the data given).

Early returns make it sure you don't even up with mutating the response somewhere later in the code. It also make more readable (imo) because not everything is nested.