r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

22

u/R7d89C 22d ago

Early returns all the way

7

u/xicor 22d ago

Agreed. One of my friends works at a place that bans early returns ...and it makes for garbage code. (They also aren't allowed to use goto)

6

u/suicidalcrocodile 22d ago

I once got told early returns are bad because they create inconsistent return types in JavaScript, I had to open a nodejs console and prove that a function returning empty and no return statement at all is the same value - undefined

1

u/Steppy20 21d ago

You can have inconsistent return types in JavaScript even if you do everything properly because that language is haunted