JavaScript Comments

A comment is defined as a line of text that is not comprehended by the JavaScript interpreter.

Comments are included to provide additional information about the source code. They make it easier to understand the code.

You can include both single-line or multi-line comments in JavaScript. A single-line comment starts with a double forward slash (//).

Example

This is a JavaScript program

document.write("Introduction to JavaScript");

The multi-line comment starts with a slash and an asterisk (/) and ends with an asterisk and slash (/).

Example

/* This is a first program

in JavaScript */

document.write("Introduction to JavaScript");