WEB TUTORIALS
PRACTICE EXAMPLES
HTML REFERENCES
CSS REFERENCES
PHP REFERENCES

How to write comments in JavaScript

Topic: JavaScript / jQueryPrev|Next

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>

Related FAQ

Here are some more FAQ related to this topic:

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties