Zum Inhalt springen
KodeTrail

Camp 1 · Schritt 2 von 18

Hello, console!

console.log, semicolons, and your first real JavaScript programs.

10 Min.+50 XPAuf Englisch angezeigt — Übersetzung ist unterwegs

The console is where JavaScript prints messages — invisible to normal visitors, indispensable to developers. Every browser has one built in (try pressing F12 sometime!). Our playgrounds show it right below the code.

console.log — your printing press

JavaScript

Three observations:

  • Text needs quotes; math doesn't.
  • Comma-separated values print with spaces between them.
  • Instructions run top to bottom, in order.

Anatomy of the line

console.log("Hello!");
  • console — a built-in object representing the console
  • .log — the method (action) we're calling on it
  • ("Hello!") — what we hand to it
  • ; — the period at the end of a JavaScript sentence

Comments

Notes for humans, ignored by JavaScript:

JavaScript
Checkpoint

What does console.log(10, 20) print?

Checkpoint

Which symbol starts a single-line comment in JavaScript?

What's next

Values, expressions, and what happens when things go wrong — learning to read errors while they're still tiny.