JS-014
JavaScript diagram about Comments: a visual example of Notes for humans
Beginner2 min~2 min read#comments#documentation#readability

Comments

Notes for humans

Goal

Learn what comments are and why programmers use them.

Explanation

  • Comments are explanations inside the code.
  • JavaScript completely ignores comments when running the program.
  • They are for people—to explain tricky parts or leave notes.
  • A single-line comment starts with //.
  • Good comments explain why something was done, not just repeat the code.

Analogy

A comment is like a sticky note. A person reads it, but JavaScript walks right past it.

Code

// User age
let age = 25;

console.log(age);

Result: 25

Common mistake

You don't need to comment every line of code. Comments should explain what isn't obvious.

Remember

  • Comments are read by people.
  • JavaScript ignores comments.
  • // creates a single-line comment.

Quick Quiz

Who uses comments?

Resources