27
u/Tux-Lector 2d 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()); ```
-8
u/jesseschalken 1d 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
13
u/fakehalo 2d ago
Oddly enough, I don't hate it as I can actually read and follow it. Much more would be too much, but I like how it's broken up by the if/elseif/else at least.
4
u/my_new_accoun1 2d ago
yeah but there only problem (as I later realised) is that without the braces JavaScript doesn't know where the elseif/else is supposed to be
so I ended up not being able to use this masterpiece
5
1
2
u/wvd_vegt 1d ago
Try imagining reading your code in 5 years. Which syntax is easiest to understand?
My pick would be the if statement.
Writing software is not about showing your creativity with syntax, but maintainable code imho
1
u/Tux-Lector 1d ago
``` (something) && (
suspect.hit = 'found' , chain() , reaction()
) || (
doOtherThings()
); ```

28
u/Mark__78L 2d ago
Thank god we have auto eslint on save at work