Skip to main content

JavaScript Example

javascript

const lesson = "Learn by building"
const completed = true

if (completed) {
  console.log("Ready for next chapter")
}

Guided tutorial track

JavaScript Tutorial

Learn JavaScript from scratch with practical examples covering variables, functions, arrays, objects, DOM manipulation, events, and browser scripting.

Tutorial overview

Start here, then move through the chapters

This tutorial is designed to be followed in order. Read the chapter, practice with the editor, test your understanding, and move toward completion.

Lessons

207

Sections

24

Access

Free

Level

beginner

Ready to begin?

Start with lesson one and follow the tutorial step by step.

Open first lesson

This tutorial teaches JavaScript from a first variable to code that reacts to a click, fetches data and updates the page - the language itself first, then the browser APIs that make it useful.

Values, a condition, and output

javascript

const name = "Ada"
const visits = 3

if (visits > 1) {
  console.log(`Welcome back, ${name}`)
} else {
  console.log(`Hello, ${name}`)
}

What JavaScript actually is

JavaScript is the language that makes a page do something. HTML describes what is there, CSS decides how it looks, and JavaScript decides what happens when someone interacts with it.

Unlike HTML and CSS it is a real programming language: variables, conditions, loops, functions and data structures. That makes it harder, and also the reason it is worth the time.

Where it runs

In every browser, with no install and no build step. Open the console on this page and you are already in a JavaScript environment.

It also runs on servers through Node, which is why it is the one language that can cover a whole product. This tutorial stays in the browser, because that is where the feedback is immediate.

What this tutorial covers

  • The basics - variables, types, operators, conditions and loops.
  • Functions and scope - parameters, return values, closures and this.
  • Data - arrays, objects, Maps and Sets, and the methods worth knowing by heart.
  • The DOM - finding elements, changing them, and responding to events.
  • Asynchronous code - callbacks, promises, async/await and fetching data.
  • Modern JavaScript - modules, classes, destructuring, generators and error handling.

Each chapter is short and runnable, and the order is deliberate: nothing uses an idea you have not met yet.

Reacting to a click

javascript

const button = document.querySelector("#go")
const output = document.querySelector("#out")

button.addEventListener("click", () => {
  output.textContent = "Clicked at " + new Date().toLocaleTimeString()
})

The part that makes it click

Five lines, and the page responds to a person. Most of what you will write professionally is a longer version of exactly this shape: find something, listen for something, change something.

Frameworks like React exist to manage that pattern at scale - but they are JavaScript underneath, and they make far more sense once this is second nature.

What you need before you start

Basic HTML, and enough CSS to recognise a class selector. You need to know what an element is before you can ask JavaScript to find one.

No maths beyond arithmetic, and no prior programming. If this is your first language, expect the first few chapters to be slower than the rest - that is normal and it passes.

How long this takes

The basics - variables, conditions, loops, functions - take a week or two of evenings, and they transfer to every other language you will ever learn.

The DOM is quick and immediately satisfying, because every change is visible. Asynchronous code is the wall most people hit, and it is worth going slowly there rather than pushing on.

You will not remember every method, and you do not need to. Knowing that something exists and what it is called is most of the skill; the exact arguments are a search away.

Common questions

JavaScript. React is a JavaScript library, and starting with it means every problem looks like a React problem when most of them are language problems wearing a costume.

The learning path

Work through these in order. Each part builds on the one before it, and every part lists what it covers and roughly how long it takes.

Part 1Beginner

JavaScript Introduction

6 lessons36 min

What is JavaScript · JavaScript Features · JavaScript Syntax

Start this part
Part 2Beginner

JavaScript Basics

3 lessons18 min

JavaScript Variables · JavaScript Data Types · JavaScript Operators

Start this part
Part 3Beginner

JavaScript Statement & Expression

7 lessons42 min

JavaScript Statements · JavaScript Expressions · JavaScript Keywords

Start this part
Part 4Beginner

JavaScript Conditions

5 lessons30 min

JavaScript if Statement · JavaScript if else Statement · JavaScript else if Statement

Start this part
Part 5Beginner

JavaScript Loops

8 lessons48 min

JavaScript for Loop · JavaScript while Loop · JavaScript do while Loop

Start this part
Part 6Beginner

JavaScript Functions

14 lessons84 min

JavaScript Functions · JavaScript Function Declarations · JavaScript Function Expressions

Start this part
Part 7Beginner

JavaScript Scope & Hoisting

6 lessons36 min

JavaScript Scope · JavaScript Block Scope · JavaScript Hoisting

Start this part
Part 8Beginner

JavaScript Arrays

14 lessons84 min

JavaScript Arrays · JavaScript Array Access · JavaScript Array push and pop

Start this part
Part 9Intermediate

JavaScript Objects

11 lessons66 min

JavaScript Objects · JavaScript Object Methods · JavaScript Object keys and values

Start this part
Part 10Intermediate

JavaScript DOM

12 lessons72 min

JavaScript DOM · JavaScript DOM Selectors · JavaScript DOM Content

Start this part
Part 11Intermediate

JavaScript Events

12 lessons72 min

JavaScript Events · JavaScript addEventListener · JavaScript Event Object

Start this part
Part 12Intermediate

JavaScript Asynchronous

12 lessons72 min

JavaScript Asynchronous · JavaScript setTimeout · JavaScript setInterval

Start this part
Part 13Intermediate

JavaScript Classes

12 lessons72 min

JavaScript Classes · JavaScript Class Constructor · JavaScript Class Methods

Start this part
Part 14Intermediate

JavaScript Type System

8 lessons48 min

JavaScript typeof · JavaScript Type Conversion · JavaScript Type Coercion

Start this part
Part 15Intermediate

JavaScript Strings

12 lessons72 min

JavaScript Strings · JavaScript Template Literals · JavaScript String Escape Characters

Start this part
Part 16Intermediate

JavaScript Numbers & Math

10 lessons60 min

JavaScript Numbers · JavaScript Number Methods · JavaScript parseInt and parseFloat

Start this part
Part 17Advanced

JavaScript Errors

8 lessons48 min

JavaScript Errors · JavaScript try catch · JavaScript throw

Start this part
Part 18Advanced

JavaScript Map & Set

5 lessons30 min

JavaScript Map · JavaScript Map Methods · JavaScript Set

Start this part
Part 19Advanced

JavaScript Dates

6 lessons36 min

JavaScript Dates · JavaScript Date Formatting · JavaScript Date Arithmetic

Start this part
Part 20Advanced

JavaScript Regular Expressions

8 lessons48 min

JavaScript Regular Expressions · JavaScript Regex Characters · JavaScript Regex Quantifiers

Start this part
Part 21Advanced

JavaScript Storage & BOM

8 lessons48 min

JavaScript localStorage · JavaScript sessionStorage · JavaScript Storing Objects

Start this part
Part 22Advanced

JavaScript Modules

6 lessons36 min

JavaScript Modules · JavaScript export · JavaScript import

Start this part
Part 23Advanced

JavaScript Generators & Iterators

7 lessons42 min

JavaScript Iterators · JavaScript Iterables · JavaScript Generator Functions

Start this part
Part 24Advanced

JavaScript Performance

7 lessons42 min

JavaScript Performance Basics · JavaScript Debounce · JavaScript Throttle

Start this part

What You Will Learn

JavaScript Introduction

JavaScript Basics

JavaScript Statement & Expression

JavaScript Conditions

JavaScript Loops

JavaScript Functions

JavaScript Scope & Hoisting

JavaScript Arrays

JavaScript Objects

Practice Live

Read the lesson, edit code in the Try-It editor, and see the result instantly.

Tutorial Features

Code examples inside chapters

Each topic is supported with practical examples so the tutorial stays easy to follow.

Practice with the Try It Editor

Open the browser editor and test what you just learned without leaving the site.

Quiz for self-check

Use the assessment flow to test whether the chapters are really understood.

Certificate after completion

Complete the learning flow and move toward a verifiable completion certificate.

How to Use This Tutorial

Step 01

Learn the chapter

Follow the lessons in order so each new concept builds on the previous one.

Step 02

Practice the example

Open the Try It Editor and apply the idea immediately while it is fresh.

Step 03

Test your understanding

Use the quiz and progress flow to confirm the topic is really understood.

Step 04

Finish with proof

Complete the tutorial journey and move toward a verifiable certificate.

Complete the tutorial with confidence

Finish the lessons, take the assessment, and move toward a certificate that can be verified on the site. The structure is meant to help you learn, practice, and complete the topic properly.

Certificate verification

Publicly verifiable after successful completion.

Why Learn JavaScript

Easy to Learn

JavaScript is explained with beginner friendly chapters and examples.

Essential Skill

Understand the core building blocks before moving into advanced topics.

Build Real Websites

Use each lesson as a practical step toward real web development.