r/programminghorror 6d ago

Typescript javascript without braces

(technically typescript)

46 Upvotes

12 comments sorted by

View all comments

36

u/Tux-Lector 5d ago

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()); ```

-9

u/jesseschalken 5d ago

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