Home > Web Front-end > JS Tutorial > body text

Summary of comments usage and precautions in javascript_javascript skills

WBOY
Release: 2016-05-16 18:01:53
Original
1259 people have browsed it

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
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template