

- 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
How to use comments to prevent JavaScript Execution?
If you want another code while working in the same code document, then use comments. Comment the previous code and add the alternative code to test it. After the testing completes, uncomment the previous code. In this way, you can test both the codes.
While using comments follow the below rules to create valid comments −
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 //-->.
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
- How do we use single line comments in JavaScript?
- How do we use multi-line comments in JavaScript?
- How to prevent duplicate JavaScript Variables Declaration?
- Does it make sense to use HTML comments on blocks of JavaScript?
- How to prevent modification of object in JavaScript ?.
- Explain Comments in JavaScript
- How to prevent gestational diabetes?
- How to prevent data corruption
- How to stop the execution of a function with JavaScript?
- How to stop a function during its execution in JavaScript?
- What are Comments in JavaScript?
- How to use JavaScript Object.defineProperty?
- How to find PHP execution time?
- How to create hidden comments in HTML?
- How to create conditional comments in HTML?