Q:

How to write comments in JavaScript

0

How to write comments in JavaScript

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Use the syntax "// text" and "/* text */"

Comments in CSS are typically used to explain the purpose of the style rules declarations. It will help you and others to understand what you were trying to do with the style rules at the time of editing style sheets. Comments are not displayed by the browsers.

Single-line comments

JavaScript single line comment begins with //, See the example below:

<script>
    function helloWorld(){
        alert("Hello World!"); // alert "Hello World!" in the browser
    }
</script>

Multi-line comments

JavaScript multiple line comment begins with /*, and ends with */.

<script>
    /*
    The function below display
    an alert dialog with "Hello World!" message
    */
    function helloWorld(){
        alert("Hello World!");
    }
</script>

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

JavaScript / jQuery Frequently Asked Questions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
How to show and hide div elements based on the sel... >>