← JavaScript tutorial

JavaScript

Introduction to JavaScript

HTML structures a page and CSS styles it; JavaScript makes it interactive, responding to clicks, updating content without reloading, validating forms, fetching new data. It runs inside a <script> tag, either directly in the page or linked from a separate .js file.

Example: writing output onto the page

<p id="output">Loading...</p>

<script>
  document.getElementById("output").textContent = "Hello from JavaScript!";
</script>

Since there's no visible browser console in this preview, document.getElementById(...) finds an element already on the page by its id, and setting .textContent replaces whatever text is inside it. Every example in this tutorial follows this same pattern: find something on the page, change it, which is, at its core, most of what JavaScript is actually used for on a real site.

Try it yourself
Ready to go further?

These free tutorials are a preview, our Frontend Development cohort covers it in depth, with a real project and a cohort alongside you. Active

Enroll in Frontend Development
Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account