Home > Article > Web Front-end > What are the two comment symbols in javascript
The two types of comment symbols in javascript are: 1. The single-line comment symbol "//" can be located at different locations in the code segment, and the syntax is "//content that needs to be commented". 2. Multi-line comment symbol "/**/", generally used at the beginning of js files to introduce author, function and other information, syntax "/* content that needs comments*/".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
JavaScript will not execute comments.
We can add comments to explain JavaScript or improve the readability of the code.
JavaScript comments have the following two methods:
Single-line comments: //Single-line comment information
Multi-line comments: /*Multi-line comment information*/
##Single-line comment
Single-line comments begin with//. Single-line comments can be placed at different locations in the code segment to describe the functions of different areas of code.
//程序描述 function toStr(a){ //块描述 //代码段描述 return a.toString(); //语句描述 }When using single-line comments, any characters or codes in the same line following
// will be ignored and will not be parsed.
Multi-line comments
Multi-line comments start with/* and end with
*/. Generally, at the beginning of the js file, the author, functions and other information are introduced.
/* * jQuery JavaScript Library v3.3.1 * https://jquery.com/ * Includes Sizzle.js * https://sizzlejs.com/ * Copyright JS Foundation and other contributors * Released under the MIT license * https://jquery.org/license * Date: 2019-08-21 T 17:24 Z */ document.getElementById("myH1").innerHTML="欢迎来到我的主页"; document.getElementById("myP").innerHTML="这是我的第一个段落。";In multi-line comments, any characters contained between the
/* and
*/ symbols are treated as comment text and ignored.
javascript advanced tutorial]
The above is the detailed content of What are the two comment symbols in javascript. For more information, please follow other related articles on the PHP Chinese website!