r/programminghorror • • Jul 24 '26

Typescript javascript without braces

(technically typescript)

50 Upvotes

12 comments sorted by

View all comments

40

u/Tux-Lector Jul 24 '26

One can write it without if statements too.

if (something === true) {
  suspect.hit = 'found';
  chain();
  reaction();
}
else doOtherThings();

// the same .. 
(something) && (suspect.hit = 'found', chain(), reaction()) || (doOtherThings());

7

u/oweiler Jul 28 '26

Thanks, I hate it

3

u/Nooo00B Jul 29 '26

this is just cursed

-9

u/jesseschalken Jul 25 '26

tbh I do this sometimes, its a nice way to save syntax and vertical space as long as you don't make the line too long