Chapter 1 · The very basics·8 min read
What JavaScript is and where it lives
JavaScript is the only language browsers understand natively. It runs directly in the page, which is why so many websites feel alive.
Chapter 1 · The very basicsLesson 1 of 6
0 of 6 lessons complete across this handbook
A language for acting
If HTML is the body of a page and CSS is the clothes, JavaScript is the hands. It listens for things, like a click or a key press, and then does something in response. This is what makes buttons, menus and forms feel alive.
You can write JavaScript inside the page in a <script> tag, or in a separate .js file. Just like with CSS, a separate file is cleaner and can be shared across pages.
The very first line
The classic first program prints a message to the browser's console, the developer tool you open by pressing F12. It is a fast, reliable way to check that your code is running at all.
javascript
// prints a message to the console console.log("Hello from JavaScript"); // alerts are easy to demo but annoying in real apps // alert("Hello!");
Knowledge checkpoint
Verifies: JavaScript basicsWhat does console.log() do?