JavaScript Tutorial
This JavaScript tutorial teaches you the programming language of the web, from your very first line of code to modern features like async/await, modules and classes.
JavaScript runs in every web browser. It makes pages interactive: it reacts to clicks, validates forms, loads data without reloading the page and updates what you see in real time. With Node.js, the same language also runs on servers, in command line tools and even in desktop apps.
Every chapter is short and contains examples. Click "Try it Yourself" to open an editor, change the code and run it right in your browser. Nothing to install.
Your First JavaScript Example
The classic first program prints a message. In JavaScript you print to the console with console.log(). In our editor, console output appears on the page.
console.log("Hello, JavaScript!");
const year = 2026;
console.log("Learning JS in", year);Hello, JavaScript! Learning JS in 2026
Why Learn JavaScript?
- It is the only language that runs natively in every browser
- It is beginner friendly: you only need a browser to start
- One language for front end (React, Vue) and back end (Node.js)
- It is one of the most in-demand skills in web development jobs
- A huge ecosystem of free libraries on npm
What This JavaScript Tutorial Covers
The chapters follow the order most developers learn the language in. You start with syntax, variables and data types, move on to operators, conditions, loops and functions, then work with strings, arrays and objects. After that you learn the DOM and events to build interactive pages, then error handling, classes, modules and asynchronous JavaScript with promises and fetch. The final chapter puts it all together in small exercises.
JavaScript Can Change a Page
JavaScript can create and modify HTML elements. This example builds a heading and a paragraph with code and adds them to the page.
const h = document.createElement("h2");
h.textContent = "Created by JavaScript";
const p = document.createElement("p");
p.textContent = "This paragraph did not exist in the HTML.";
document.body.append(h, p);(A heading "Created by JavaScript" and a paragraph appear on the page)
JavaScript vs Java
Despite the name, JavaScript is not related to Java. The name was a marketing choice in 1995. Java is a compiled, class-based language; JavaScript is a dynamic language standardized as ECMAScript. Each year a new ECMAScript version adds features, and this tutorial uses modern syntax (ES2023 and later) that all current browsers support.
Frequently asked questions
Is JavaScript hard to learn for beginners?
No. JavaScript is one of the easiest languages to start with because you can run it in any browser. Basic syntax takes a few weeks; mastering async code and the ecosystem takes longer.
Do I need to learn HTML before JavaScript?
Basic HTML and CSS help a lot, because most JavaScript in the browser works with page elements. You can, however, learn core JavaScript syntax without them.
How long does it take to learn JavaScript?
Most learners get comfortable with the fundamentals in one to three months of regular practice. Building real projects is the fastest way to go further.