Code Editor
Learn
Introduction to JavaScript

Comments

As we write JavaScript, we can create comments in our code.

Programs do not evaluate comments when you run them. In other words, they exist just for human readers. Good comments are useful for you and other developers, because they describe what the code does.

There are two types of code comments in JavaScript:

  1. A single line comment will comment out a single line and is denoted with two forward slashes // preceding a line of JavaScript code.

    // The first 5 decimals of pi console.log('Pi is equal to ' + 3.14159);
  2. A multi-line comment will comment out multiple lines and is denoted with /* to begin the comment, and */ to end the comment.

    /* console.log('All of this code'); console.log('Is commented out'); console.log('And will not be executed); */
Report a Bug
If you see a bug or any other issue with this page, please report it here.