One-line comments start with the two forward slash characters //.
Multiline comments start with a forward slash and an asterisk /* and end with an asterisk and a forward slash */.
// This comment occupies a line of its own alert('Hello'); alert('World'); // This comment follows the statement /* An example with two messages. This is a multiline comment. */ alert('Hello'); alert('World');
The content of comments is ignored, so if we put code inside /* … */ it won’t execute. Sometimes it comes in handy to temporarily disable a part of code:
/* Commenting out the code alert('Hello'); */ alert('World');