Home Web Front-end JS Tutorial Summary of comments usage and precautions in javascript_javascript skills

Summary of comments usage and precautions in javascript_javascript skills

May 16, 2016 pm 06:01 PM
Comment

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 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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Conveniently use PyCharm shortcut keys to implement multi-line comments Conveniently use PyCharm shortcut keys to implement multi-line comments Jan 27, 2024 am 08:02 AM

Conveniently use PyCharm shortcut keys to implement multi-line comments

How to Optimize the Maintainability of Java Code: Experience and Advice How to Optimize the Maintainability of Java Code: Experience and Advice Nov 22, 2023 pm 05:18 PM

How to Optimize the Maintainability of Java Code: Experience and Advice

How to comment multiple lines in go language How to comment multiple lines in go language Jan 05, 2023 am 10:59 AM

How to comment multiple lines in go language

How to add notes to saved passwords on iPhone How to add notes to saved passwords on iPhone Feb 28, 2024 pm 07:41 PM

How to add notes to saved passwords on iPhone

PyCharm Annotation Operation Guide: Optimizing the Code Writing Experience PyCharm Annotation Operation Guide: Optimizing the Code Writing Experience Feb 21, 2024 pm 06:27 PM

PyCharm Annotation Operation Guide: Optimizing the Code Writing Experience

A detailed explanation of annotations in golang A detailed explanation of annotations in golang Mar 21, 2023 pm 07:38 PM

A detailed explanation of annotations in golang

The php language supports several comment styles The php language supports several comment styles Feb 15, 2022 pm 02:05 PM

The php language supports several comment styles

Share tips for quickly commenting code in PyCharm to improve work efficiency Share tips for quickly commenting code in PyCharm to improve work efficiency Jan 04, 2024 pm 12:02 PM

Share tips for quickly commenting code in PyCharm to improve work efficiency

See all articles