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

How to make multi-line comments in javascript

藏色散人
藏色散人Original
2021-04-09 15:09:036252browse

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>

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!

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