Home > Web Front-end > JS Tutorial > How to make multi-line comments in javascript

How to make multi-line comments in javascript

藏色散人
Release: 2023-01-04 09:35:44
Original
6246 people have browsed it

How to make multi-line comments in javascript: first create an HTML sample file; then add a script tag in the head tag; then write javascript code in the script tag; finally use "/*. ..*/" symbols can be used for multi-line comments.

How to make multi-line comments in javascript

The operating environment of this article: windows7 system, javascript1.8.5&&html5 version, Dell G3 computer.

js single-line and multi-line comment writing format

The role of comments is to improve the readability of the code and help yourself and others read and understand the JavaScript code you write. , the content of the annotation will not be displayed on the web page. Comments can be divided into two types: single-line comments and multi-line comments.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>JavaScript-注释很重要</title>
        <script type="text/javascript">
            document.write("我是单行注释&#39;//&#39;");//该语句在网页中输出的单行注释内容不展示
            document.write("我是多行注释&#39;/*注释内容*/&#39;");
            /*
            哈哈,我是多行注释
            神奇的js把我隐藏了,看不见
            记得养成良好的注释习惯
            */
        </script>
        <style type="text/css">
            div::selection{
                background-color: #00FFFF;
                /* color: #fff; */
            }
        </style>
    </head>
    <body>
        <div>html与css注释还记得如何书写吗</div>
        <!-- <div>html与css注释还记得如何书写吗</div> -->
    </body>
</html>
Copy after login

Summary: The comment content is generally placed at or around the end of the statement that needs to be explained. For single-line comments, add the symbol "//" before the comment content. At the same time, multi-line comments start with "/*" and end with "* /"End, did you find that the multi-line comments of javascript are the same as the comments of css

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of How to make multi-line comments 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