JavaScript Comments

You are Here:

JavaScript Comments

Javascript Comments are solely for your benefit. It is useful for you as a programmer because you can add explanations to your code that make it easier to remember what you were doing when you come back to your code later.

Types of Comments

There are two types of comments available in JavaScript, they are

  • Single Line Comment
  • Multi Line Comment

Single Line Comment

Single line comments start with //.

Any text following // will be ignored, until the next line.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> // x is a variable var x = 1; document.write("x = " +x); </script> </body> </html>

Syntax

// This is Single Line Comment /* This is Multi line
Comments */

Multi Line Comment

Single line comments start with /* and end with */.

Any text following /* will be ignored, until */.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> /*x is a variable */ var x = 1; document.write("x = " +x); </script> </body> </html>

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author