

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are Comments in JavaScript?
JavaScript supports both C-style and C++-style comments, thus
- Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript.
- Any text between the characters /* and */ is treated as a comment. This may span multiple lines.
- JavaScript also recognizes the HTML comment opening sequence <!--. JavaScript treats this as a single-line comment, just as it does the // comment.
- The HTML comment closing sequence --> is not recognized by JavaScript so it should be written as //-->.
Example
The following example shows how to use comments in JavaScript.
<script> <!-- // This is a comment. It is similar to comments in C++ /* * This is a multiline comment in JavaScript * It is very similar to comments in C Programming */ //--> </script>
- Related Questions & Answers
- What are JSP comments?
- What are the various types of comments in JavaScript?
- What are comments in Java language?
- What are the comments in C#?
- Explain Comments in JavaScript
- What is the difference between comments /*...*/ and /**...*/ in JavaScript?
- What are the several ways to add comments in MySQL query?
- Removing comments from array of string in JavaScript
- What is the difference between single-line and multi-line comments in JavaScript?
- Comments in Java
- Comments in C#
- Comments in Perl
- Comments in Python
- Java comments.
- HTML Comments
Advertisements