JavaScript comments
JavaScript comments can be used to improve the readability of your code.
JavaScript Comments
JavaScript will not execute comments.
We can add comments to explain JavaScript or improve the readability of the code.
Single-line comments begin with //.
This example uses a single line comment to explain the code:
php中文网(php.cn) 注释:注释不会被执行。
Run the program and try it
JavaScript multi-line comments
Multi-line comments start with /* and end with */.
The following example uses multi-line comments to explain the code:
php中文网测试实例 注释:注释块不会被执行。
Run the program to try it
Use comments to block execution
In the following example, the comment is used to prevent the execution of one of the lines of code (can be used for debugging):
php中文网(php.cn) 注意: 注释块不会被执行
Run the program to try it
Note : Multi-line comments are used the same as above. Just wrap the code blocks that do not need to be executed with multi-line comments.
Use comments at the end of the line
Like this
var x=5; // Declare x and assign 5 to it