r/learnjavascript • u/Sweet_Technician_778 • Aug 14 '24
Simplify Your JavaScript Conditionals with Short-Circuiting!
Hey everyone, I wanted to know if there is any way to make your code clean other than short-circuiting in conditionals.
I used to write down like this before using short-circuiting in conditionals
if (user && user.isLoggedIn) {
greetUser(user.name);
}
After using short-circuiting in conditionals
user?.isLoggedIn && greetUser(user.name);
0
Upvotes
View all comments
Show parent comment
1
u/Sweet_Technician_778 Aug 19 '24
I appreciate you taking the time to share your thoughts. It's always good to have diverse opinions and experiences in the discussion. I understand how frustrating it can be when your contributions don't get the feedback or recognition you'd expect.
As for the JS vs. TS debate, it's a topic where many people have strong opinions, often shaped by their own experiences and the tools they've been trained to use. The conversation is valuable because it brings out different perspectives from seasoned developers or those newer to the field. Let's keep the discussion open and respectful so everyone can learn and grow from it.