lundi 8 octobre 2018

If else statement order of evaluation

Is it even possible to reach the second statement in Javascript if a is true?

if (a) {
    ...
} else if (a && b) {
    ...
} else if (b) {
    ...
} else {
    ...
}

Can I omit the last else statement or it is an obligatory expression part?

Also is it possible to omit curly braces like for a regular if statement?

if (a && b) ...
else if (a) ...
else if (b) ...
else ...

Aucun commentaire:

Enregistrer un commentaire