To add to the code of several commands, you can put one after another separating them using the semicolon.
Usually, each command is written on a separate line so the code is easier to read:
You can omit the semicolon in many cases:
This will work too:
However, it is important that “in many cases” does not mean “always!”
For example, run this code:
alert(3 + 1 + 2);
Single-line comments begin with a double slash “//”. The text is a comment to the end of the line:
// command below says "Hello" alert( 'Hello' ); alert( 'World' ); // Second message is output separately
Multiline comments begin with a slash-asterisk “/ *” and end with an asterisk-slash “* /”, like this:
/* Example with two messages Here is a multiline comment */ alert( 'Hello' ); alert( 'Wrold' );
All the content of the comment is ignored. If you put the code inside “/ * … * /” or after “//” it will not be executed.
Nested comments are not supported!
This code will not work:
/ * / * Nested comment?!? * / * / alert ( 'World');
Thanks for your attention!