➢JavaScript comments can be used to explain JavaScript code, and to make it more readable.
➢JavaScript comments can also be used to prevent execution, when testing alternative code.
Single Line Comments
➢Single line comments start with //.
➢Any text between // and the end of the line will be ignored by JavaScript (will not be executed).
EXAMPLE:
document.getElementById("demo").style.fontSize = "15px";// Giving font Size
document.getElementById("demo").style.color = "green";// Giving color
document.getElementById("demo").style.back groundColor = "orange";// Giving background color }
Multi-line Comments
➢Multi-line comments start with /* and end with */.
➢Any text between /* and */ will be ignored by JavaScript.
EXAMPLE:
document.getElementById("demo").style.fontSize = "15px";// Giving font Size
document.getElementById("demo").style.color = "green";/*
document.getElementById("demo").style.back groundColor = "orange";// Giving background color */}