Single Line Comment#
A single line comment starts with // and continues until the end of the line.
// Everything on this line is commented.
console.log("Hello, World!");You can also write it inline, to the right of your code:
console.log("Hello, World!"); // Everything to the right is commented.
Block Comment#
A block comment starts with /* and ends with */. Everything in between is ignored.
/*
This is a block comment.
It can span
multiple lines.
*/
console.log("Hello, World!");You can also use block comments in a single line or inline:
/* Block comment on a single line */
console.log("Hello, World!"); /* Block comment inline */Always close a block comment. If you don’t, everything after it will be treated as part of the comment.