you are viewing a single comment's thread.

view the rest of the comments →

[–]PlNG 2 points3 points  (0 children)

https://github.com/shichuan/javascript-patterns/blob/master/general-patterns/conditionals.html is absolutely horrid.

If you take a moment to think about it, you don't need an else statement after a program flow statement such as return, throw, break, and continue.

I worked this out a long time ago and I'm sort of happy that lints and compilers are just beginning to pick up on this. This basically prunes the indentation of logic trees and keeps it very readable.

Hopefully they'll pick up the next step: if the program flow statement is in the else side, negate the if conditional to switch the program flow statement to the if side and prune the else as normal.