Clean • Professional
JavaScript comments are notes in your code that the computer ignores. They help explain your code, remind you why you wrote it, or guide teammates—like sticky notes for programmers.
Explain what your code does (e.g., “Calculate total price”).
//)A single-line comment starts with //. Everything after it on the same line is ignored.
// This prints a greeting
console.log("Hello, World!");
// Disable a line temporarily
// console.log("This won’t run");
console.log("Code still works!");
/* ... */)A multi-line comment starts with /* and ends with */.
Everything between is ignored—even across multiple lines.
/* This block of code
calculates total price with tax */
let price = 100;
let tax = price * 0.1;
console.log(price + tax);
/* Temporarily disable multiple lines
let x = 10;
console.log(x);
*/
console.log("Only this runs!");Â