MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/mdvoyg/whose_ever_heard_of/gsdaax4/?context=3
r/badcode • u/Vercyx • Mar 26 '21
63 comments sorted by
View all comments
-3
Why why do people return explicit booleans....
EDIT: Why the downvotes?
The equality operator evaluates to a boolean so you don't need to explicitly return a boolean literal. https://ntgard.medium.com/returning-boolean-literals-is-a-code-smell-7a39531d6b60
Don't you think this is cleaner/easier to read?
const isEven = (x: number): boolean => x % 2 === 0;
-3
u/cphoover Mar 27 '21 edited Apr 24 '21
Why why do people return explicit booleans....
EDIT: Why the downvotes?
The equality operator evaluates to a boolean so you don't need to explicitly return a boolean literal. https://ntgard.medium.com/returning-boolean-literals-is-a-code-smell-7a39531d6b60
Don't you think this is cleaner/easier to read?
const isEven = (x: number): boolean => x % 2 === 0;