Get the App
SLTechnology News&Howtos  ›  Development  › 

Can Javascript be annotated with double slashes

Shulou Source: shulou.com Published: 2022-06-01 10:30:41 10月05日 Update

This article mainly introduces whether Javascript can use double slash comments, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

In JavaScript, you can use double slashes to comment; you can use "/ /" to comment on JavaScript code on a single line, the syntax is "/ / single-line comment content", and you can use "/ *" and "* /" to comment on multiple lines of JavaScript code. The syntax is "/ * multi-line comment content * /".

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

Can Javascript be annotated with double slashes?

We can add comments to interpret the JavaScript or improve the readability of the code.

One-line comments begin with / /.

This example uses single-line comments to explain the code:

Example

/ / output title: document.getElementById ("myH1") [xss_clean] = "Welcome to my home page"; / / output paragraph: document.getElementById ("myP") [xss_clean] = "this is my first paragraph."

Multiline comments begin with / * and end with * /.

The following example uses multiple lines of comments to explain the code:

Example

/ * the following code will output a title and a paragraph and will represent the beginning of the home page * / document.getElementById ("myH1") [xss_clean] = "Welcome to my home page"; document.getElementById ("myP") [xss_clean] = "this is my first paragraph." Thank you for reading this article carefully. I hope the article "can Javascript be annotated with double slashes" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Comments code slashes paragraphs articles multiple lines home page interpretation output content examples title grammar this is faceted representative value example interest readability Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Technology Linux MariaDB Docker