AI Hints
JavaScript · Lesson 4 of 138

Comments and Statements

Notes and semicolons.

⏱ 2 min read▶ Video at 3:23🎓 Free
Watch this lesson in the JavaScript courseWatch on YouTube ↗Full JavaScript course

A program is a list of instructions, called statements, that run from top to bottom. And sometimes you want to leave a note for humans, that the computer ignores. That's a comment.

Comments and Statements
From the video: Comments and Statements
  • Statements run top to bottom
  • Notes for humans
  • Comments

Comments

Two slashes start a comment that runs to the end of the line. Slash star starts a comment that can cover many lines, until star slash. JavaScript skips them completely. Each statement usually ends with a semicolon. Run it. Only the real statements print.

app.jsjavascript
// This is a comment. JavaScript ignores it.
console.log("Line one");

/* This comment
   covers several lines */
console.log("Line two"); // a comment can end a line too
Output
Line one
Line two

Semicolons

Semicolons mark the end of a statement, like a full stop in a sentence. JavaScript can usually add missing ones for you, but not always correctly, so most style guides recommend writing them yourself. In this course, every statement ends with a semicolon.

keyvalue
//one-line comment
/* */multi-line comment
;ends a statement
Ordertop to bottom

Summary

Statements run top to bottom, end with semicolons, and comments are notes the computer ignores. Next, storing values in variables.

Key takeaways
  • // and /* */
  • End with ;
  • Top to bottom
Next up: Variables with let — boxes for values