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


Does anyone know if this is JS-specific or not? Braceless if-statements exist in most languages and now I'm curious if those languages have else-if explicitly defined in their grammars or not.


I believe it's also true for C / C++ / Java. I didn't go check just now, but it has always been my understanding that this was how they worked.


Yes, as far as I know this is how a lot of languages, at least most "C-Style language" will do this. You can also look at the grammar of a lot of languages and figure out from there that it would have to do that as else if is not being defined as one keyword. They are separate keywords.

The same is also in python with elif, which j believe is actually just syntatic sugar in the end, and would end up producing the same code.

code of conduct - report abuse