Single-line comments start with two forward slashes (
//) and continue until the end of the line. Everything after the slashes is considered a comment and will not be executed.
// This is a single-line comment
let x = 5; // Declare a variable and assign it the value 5
In the example above, the first line is a single-line comment. The second line contains a single-line comment after the code, providing a brief explanation of the code's purpose.
Multi-line comments start with a forward slash followed by an asterisk (
/*) and end with an asterisk followed by a forward slash (
*/). You can use multi-line comments to write longer explanations that span multiple lines.
This is a multi-line comment.
It can span multiple lines without any issue.
let y = 10;