Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
Semicolon after statement
Shouldn't the semicolon be obligatory also after the whole "if" statement, not only inside it? (after curly braces)
3 ответов
+ 8
You put it only where code is executable.
example:
alert("hi"); //action
if (a == 1){} //the action isn't performed by the "if", it's performed by the code inside it...
+ 6
Well... you can do this :
alert(prompt("text"));
(no need for semicolon after prompt because it returns value to alert thus isn't considered as action)
i don't think there are any exceptions, and if you remove it there are 50% chances that the code will malfunction (because some functions are actions only and don't return value)...
+ 3
Thanks a million! One, ok two more questions: are there any exceptions? Will it change anything if I'd add semicolon after i.e. the statement you mentioned?