Comments

// this is a single line comment

In JavaScript, anything that follows two forward slashes on the same line is considered a comment and is ignored by the browser. The comment lasts as long as the rest of the line, as long as it's after the slashes. This is done so programmers can easily leave information for anyone reading the code, but it can also be used to make the interpreter ignore single line statements (single instructions, we'll talk more about statements in the next section). This can be useful when troubleshooting.

Multiple Line Comment "/* */"

There's also a way of commenting across multiple lines. It's the same as in CSS. If we split the forward slashes and place asterisks between them, anything between the asterisks will be "commented out".

//this is a single line comment
/*this is a single line comment*/

This line will be interpreted as code

/*

This is

a multiple line

comment

*/

This line will also be interpreted as code

In the next section, we'll talk about how to define JavaScript statements to clearly separate one command from another.

Next