Skip to main content

What JavaScript Does

beginner10 min readLesson 27 of 143

The browser's programming language: what it can do, where it runs, and how to see it run with console.log β€” your first window into every program you will ever write.

HTML is content, CSS is appearance. JavaScript is behavior β€” the only programming language browsers run natively. Every interactive thing on the web β€” autocomplete, drag-and-drop, live scores, form validation β€” is JavaScript changing the page after it loads.

Where it runs

A browser downloads your .js file and executes it, top to bottom, inside the page. The same language also runs on servers (Node.js) β€” that is how Code Journey grades your challenges β€” but in this module the browser is home.

Your first command: console.log

console.log("Hello, web!");

`console.log(...)

prints values to the console β€” a panel built into every browser (open it with F12 or right-click β†’ Inspect β†’ Console). Programmers live in the console: it is where you check what your code actually did. In these challenges the grader reads your console output, so console.log is how your code talks to the tests.

Statements end with semicolons (usually)

A statement is one instruction. Style guides differ, but these challenges expect a semicolon at the end of each statement:

console.log("one");
console.log("two");

Comments

Text after // is ignored by the browser β€” notes for humans:

// greet the learner
console.log("Welcome!");

Errors are normal

Type consolelo.g("x") and the console shows a red error with a line number. Errors are not failure β€” they are the browser telling you exactly where to look. Every professional reads errors dozens of times a day.

What you learned

  • JavaScript = behavior; it runs in the browser after the page loads
  • console.log prints values; the console is your feedback loop
  • Statements are separated with semicolons; // starts a comment
  • Errors point at the problem β€” read them

Next: storing values with variables.

Now practice

What JavaScript Does β€” PracticeHands-on practice for β€œWhat JavaScript Does”: apply what you just learned in what-javascript-does.1 challenge Β· Β· ~5 min