I mean, else if is syntactic sugar for else { if ... } as opposed to being a special language construct (like Python's elif), but it does exactly the same thing. You could write basically the same article about how C pointers are just integers, or about how a switch statement is just syntactic sugar for something nasty-looking with goto, or any number of things. A more honest post might talk about how a CPU can't execute JavaScript, so it gets translated into machine code - else if and else { if look the same at that level, since they mean the same thing. Which one is syntactic sugar for the other doesn't really matter, and, as others have mentioned in this thread, I'd argue that actually the else { if version adds an additional language construct (which is why if (true) alert('alert!') works) and is therefore the more honest version.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I mean,
else if
is syntactic sugar forelse { if ... }
as opposed to being a special language construct (like Python'selif
), but it does exactly the same thing. You could write basically the same article about how C pointers are just integers, or about how aswitch
statement is just syntactic sugar for something nasty-looking withgoto
, or any number of things. A more honest post might talk about how a CPU can't execute JavaScript, so it gets translated into machine code -else if
andelse { if
look the same at that level, since they mean the same thing. Which one is syntactic sugar for the other doesn't really matter, and, as others have mentioned in this thread, I'd argue that actually theelse { if
version adds an additional language construct (which is whyif (true) alert('alert!')
works) and is therefore the more honest version.