HTML gives a page its structure and CSS makes it look good. JavaScript lets the page respond to what the user does. A button can open a menu, a form can show an error, and a page can load new data without reloading.
JavaScript is a programming language. You write instructions, and the browser follows them in order. That is different from HTML and CSS, which describe what a page is and how it looks. JavaScript describes what should happen.
A first taste
Press Run, then click the button in the result.
<button id="hello">Say hello</button>
<p id="message"></p>
<script>
const button = document.querySelector("#hello");
const message = document.querySelector("#message");
button.addEventListener("click", () => {
message.textContent = "Hello from JavaScript!";
});
</script>
The HTML creates a button and an empty paragraph. The script finds both, then says: when the button is clicked, put some text in the paragraph. You will learn every line of this during the course, so do not worry if it looks strange right now.
Where JavaScript runs
JavaScript needs a place to run, called an environment or runtime.
- Web browsers (Chrome, Firefox, Safari, Edge) run JavaScript on web pages. This is where the course starts.
- Node.js and similar runtimes run JavaScript outside the browser, for example on a server. You will meet it briefly in Browser, Node.js and Other Environments.
Browser JavaScript can change the page, react to clicks and typing, store small amounts of data, and talk to servers. It cannot read files on your computer or run programs on it unless you allow something specific. Browsers keep web pages in a sandbox on purpose.
What the course covers
You will start with the language itself: values, decisions, loops and functions. Then you will use it on real pages: the DOM, events, forms and fetching data. After that come modules, modern features, and the habits that make code safe and easy to debug.