After an if statement, one statement is executed under that condition. Something like 'return false;' is one statement - you see that because after each statement, there's a semicolon (';').
If you want to apply the condition for several statements, you can merge them by putting curly braces around them ('{}').
So for one statement, the braces are not necessary, but can be useful for better readability of the code.
Note that the 'else if' statement is not actually it's own thing, but rather an 'else' triggering an 'if'. You could also put an 'else' and an 'if' within braces, but if you have very long 'else if' chains, the braces get really messy (sure I can tell :D).
So if you have a 'while' or 'do while' or 'for' or anything else that already groups things together, just put i.e. 'if (condition) while (condition){}'. This works for all loops and conditional statements:
If, else, for, while, do while. Switch-case and every other thing only at the end of such "chains".
'Else if' example:
else if (a<b) {
alert.("Jay!");
}
is equal to
else {
if (a<b){
alert.("Jay!");
}
}
Another example:
while(a<b) for(xyz){
alert.("Jay!");
}
Couldn't resist it :D (this is actually valid code: )
if(a<b) while(c>=d) for(xyz) switch(e){
case 1: alert('Hey there!'); break;
case 2: alert('Coding is fun'); break;
case 3: alert('Just wait for the goofy little projects xD'); break;
}