← Back to Roadmap

Comments

Easy

In plain terms

Comments let you add notes in code that are ignored when the program runs. Use // for single-line and /* */ for multi-line comments. Good comments explain why, not what.

What you need to know

  • Single-line: //
  • Multi-line: /* */
  • Comments are ignored by the engine

Try it yourself

Copy the code below and run it in your browser console or a code editor:

// Single-line comment

/* Multi-line comment
   can span several lines
   and is useful for longer explanations */

const price = 99; // Inline comment explaining the value

Learn more

Dive deeper with these trusted resources: