Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

Multi-line Comments

Multi-line comments in JavaScript start with /* and end with */, with all text between these delimiters ignored by JavaScript. The following example uses a multi-line comment, or comment block, to explain the code.

Example

/*
The code below will change
the heading with id = “myH”
and the paragraph with id = “myP”
in my web page:
*/

document.getElementById(“myH”).innerHTML = “My First Page”;
document.getElementById(“myP”).innerHTML = “My first paragraph.”;

Single-line comments are the most commonly employed form.

Block comments, on the other hand, find frequent use in formal documentation.