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

How to comment in a single line in javascript

藏色散人
Release: 2023-01-07 11:43:06
Original
3467 people have browsed it

In JavaScript, a single-line comment is represented by double forward slashes "//", which can be used before and after a statement. Its syntax is such as "//This is a single-line comment", which means "//" All characters after the symbol until the end of the line will be ignored by JavaScript.

How to comment in a single line in javascript

The operating environment of this article: Windows 7 system, javascript1.8.5, Dell G3 computer.

How to comment in a single line in javascript?

Single-line comments

In JavaScript, single-line comments are represented by double forward slashes (//) and can be used before and after a statement.

Syntax:

// 你的代码在这里
Copy after login

All characters following the // syntax until the end of the line will be ignored by javascript.

Example 1: Add

<script>
//这是单行注释
document.write("hello javascript");
</script>
Copy after login

before the statement Example 2: Add

<script>  
var a=10;  
var b=20;  
var c=a+b; 
document.write(c);//输出10和20之和  
</script>
Copy after login

after the statement Related video tutorial sharing: javascript advanced video

The above is the detailed content of How to comment in a single line in javascript. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!