Home  >  Article  >  Web Front-end  >  Summary of comments usage and precautions in javascript_javascript skills

Summary of comments usage and precautions in javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:01:531256browse

There are two ways to comment in JavaScript:

Single-line comments: //

Multi-line comments: /* */

Comments are mainly to make the program we write more convenient It is readable and convenient for others to make secondary modifications

Look at the example below, we annotated the regular expression with /* */, and a syntax error was reported during runtime

Copy code The code is as follows:

/*
var rm_a = /a*/.match (s);
*/

So block-level comments are unsafe. If we make such a mistake in our code, it will be difficult to troubleshoot

So it is best to use single-select comments // instead of multi-line comments /* */

JavaScript comments
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn