
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
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 Articles
- How do we use single line comments in JavaScript?
- How do we use multi-line comments in JavaScript?
- Does it make sense to use HTML comments on blocks of JavaScript?
- How to prevent duplicate JavaScript Variables Declaration?
- How to prevent modification of object in JavaScript ?.
- How to stop the execution of a function with JavaScript?
- How to stop a function during its execution in JavaScript?
- Explain Comments in JavaScript
- How to auto like all the comments on a Facebook post using JavaScript?
- How to use JavaScript Object.defineProperty?
- Is it possible to write to MongoDB console in JavaScript execution?
- What are Comments in JavaScript?
- How to find PHP execution time?
- How to add comments in MySQL Code?
- How to create hidden comments in HTML?
