DEV Community

Discussion on: Rethinking JavaScript: The if statement

Collapse
 
samsonasik profile image
Abdul Malik Ikhsan • Edited

if you do return early in function, you don’t need else. Using if is ok imo, with reduce else with return early when possible.

Collapse
 
joelnet profile image
JavaScript Joel

I love early returns and I use them in codebases that are imperative and OOP.

But when creating a functional codebase, 98% of my functions have a single statement, and that statement is a return.

When you eliminate statements and blocks, you will find that your codebase naturally becomes more functional.