Introduction
Overview
JavaScript is the programming language of the web. Every modern browser can run it, which is why it powers almost every interactive page you use — from a form that checks your email address as you type, to maps you can drag, to full applications such as online editors and video players.
It is also far more than a browser language today. With Node.js, the same JavaScript runs on servers, in command-line tools, in build systems and on your own computer. Learn it once and you can work on both the front end (what people see) and the back end (the servers behind it).
A short history
JavaScript was created in 1995 at Netscape, in about ten days, to make web pages a little more interactive. Despite the name, it has almost nothing to do with Java — the name was a marketing decision.
The language is standardised by a committee called TC39 under the name ECMAScript. Since 2015 (a release often called “ES6” or “ES2015”) a new version comes out every year, adding features such as let and const, arrow functions, classes, modules and async/await. This course teaches modern JavaScript and points out older styles only when you are likely to meet them in existing code.
Is it “JavaScript” or “ECMAScript”? ECMAScript is the name of the specification. JavaScript is what everyone calls the language. In practice they mean the same thing.
Where JavaScript runs
Your code is plain text. To run it, you need a JavaScript engine — a program that reads the text and executes it. Every browser ships with one, and Node.js wraps Google’s V8 engine so you can run JavaScript outside a browser.
The core language — variables, functions, objects, arrays, classes, promises — is identical in both places. What differs is the set of extra tools the environment provides:
- In the browser you get the DOM (to read and change the page), events (clicks, key presses),
fetch(to talk to servers), storage and timers. - In Node.js you get modules for reading and writing files, creating web servers, running other programs, and the npm ecosystem of packages.
This course focuses on the language itself and the browser. Everything you learn here carries straight over to Node.js.
What you’ll learn
This course takes you from your first line of code to building interactive pages, in 14 chapters grouped into six stages:
- Getting started, variables and control flow — the building blocks every program uses: statements, values, types, operators,
if,switchand loops. - Functions, objects and arrays — organising code into reusable pieces and storing data in useful shapes.
- Built-in objects, classes and errors — Maps, Sets, dates, regular expressions, prototypes and classes, and handling failure well.
- Asynchronous code and modules — the event loop, callbacks, promises,
async/await,fetch,importand npm. - The DOM and browser APIs — changing the page, responding to events, working with forms, saving data and using timers.
- Advanced concepts — iterators, generators, symbols, proxies and immutability.
Each stage uses ideas from the stages before it. Functions appear everywhere after chapter 4; objects and arrays are the backbone of every program after that; promises are essential before you can use fetch. That is why it pays to go in order.
How to use these lessons
Each topic follows the same pattern:
- Read the explanation. Sections are short and focused on one idea at a time.
- Try the examples. Open the browser console (you’ll set this up in the next topic) and type the code in. Change values and see what happens.
- Do the exercise. Most topics end with a small task. Try it before you open the solution.
- Check the summary and press Mark as complete. Your progress is saved in your browser.
Use the sidebar to see where you are in the course, and the “On this page” panel to jump between sections.
Tip: Typing the examples out, rather than copying them, helps you remember the syntax much faster. Making (and fixing) small typos is part of learning.
What you need
- A computer with a modern browser (Chrome, Firefox, Safari or Edge).
- A free code editor — the next topic walks you through installing one.
- No prior programming experience. If you have some, you will move faster through the first chapters.
A first taste
Here is a complete JavaScript program. It prints a message to the console:
console.log('Hello, world!');And here is a slightly bigger one that uses a variable, a function and a condition — three ideas you will master in the next few chapters:
const hour = new Date().getHours();
function greet(name) {
if (hour < 12) {
return `Good morning, ${name}!`;
}
return `Good afternoon, ${name}!`;
}
console.log(greet('Asha'));Don’t worry if some of this looks unfamiliar. By the end of the Functions chapter you’ll be able to read every line — and write programs much larger than this. You’ll run your first script yourself in a couple of topics’ time.
Summary
- JavaScript runs in every browser and, with Node.js, on servers and your own computer too.
- The language is the same everywhere; what changes is the set of built-in tools (APIs) around it.
- The course has 14 chapters that build on each other, so work through them in order.
- Read, type the examples yourself, then do the exercise — and mark the topic complete.