JavaScript Comments

 

In JavaScript, there are two ways to comment the statements a) // and b) /* */. In our example "commented statements" and "document.getElementById("myP").innerHTML = "My first paragraph.";" are commented out. See the code

 
 
 
<!DOCTYPE html> <html> <body> <div id="mydiv"></div> <script> // commented statements document.getElementById("mydiv").innerHTML = "My First Page"; /* document.getElementById("mydiv").innerHTML = "My first paragraph."; */ </script> <p><strong>Note:</strong> The comments are not executed.</p> </body> </html>
Output