No true, because with such syntax else if is side-effect (i.e. it comes for free). In other words there is no else if syntax, there is only if and else here.
But if the chain of the related If's occur inside of a function and each would execute a [return] statement, then the net effect of multiple if's matches using else if. However, it'd still be better practice to use [else if] whenever it doesn't make sense to test for the next condition, if the previous one was true.
In your case, whether you need an else clause depends on whether you want specific code to run if and only if neither of condition1, condition2, and condition3 are true. else can be omitted for any if statement, there is nothing special in the last if of an if / else if chain. This is documented in any JavaScript grammar, e.g. in the specification.
I cannot figure out how to use a simple if/elif/else structure in bash. I cannot believe how something as trivial as that can be so unintuitive and difficult. I've already spent quite a bit of time
Not the same. 'else if' is generally to be preferred, because you can keep inserting or appending more of them indefinitely, or append an 'else', whereas with the other form you have to endlessly mess around with braces to get the same effect, and you risk altering the semantics, as indeed you have done in your second sample.
Can you explain me why } must precede else or else if in the same line? Are there any other way of writing the if-else if-else statement in R, especially without brackets?
One reason very old languages use this distinct syntax instead of "else if" is that the "else if" introduces a grammar ambiguity. Old parser generators were hard to teach about what to do for ambiguities, so we avoided them.
93 Python try-else What is the intended use of the optional else clause of the try statement? The intended use is to have a context for more code to run if there were no exceptions where it was expected to be handled. This context avoids accidentally handling errors you did not expect.