loading...

re: There's no "else if" in JS VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Another blind gospel: braces around if-statements imply that people don't understand what braces do (they turn a group of statements into a single ...
 

I agree it's interesting that you can't drop the braces around function bodies (which hadn't occurred to me before) but the example in the post, of where else if ... is actually else { if ... } seems obvious. Isn't that behaving exactly how it's written, and isn't that how everyone would expect it to work if they'd never seen the language before?

 

It's not.
Because we're always encouraged to use {} in some ways, and we learn by memory to use those, without knowing the why.
During the first approach to a language, you cannot be so deeply analytic, because you've to trust the rules, or you will never go on.
After the totally beginner phase, you should start to ask yourself the why.

Have you ever encountered a bug caused by missing parentheses? Being consistent improves code readability and makes it easier to identify bugs.

It's not about... DON'T USE PARENTHESES :D It's all about know the why of parentheses

code of conduct - report abuse