Skip to content
Devtoolry

JavaScript Examples

Classic JavaScript programs in modern JavaScript (let/const, arrow functions, array methods), each with its exact output, a step-by-step explanation, common mistakes and exercises. Every output was produced by running the program.

Each example opens in the online JavaScript Compiler with one click, so you can change it and run it straight away, or press Visualize step by step to watch the program run line by line with its variables and call stack. Everything runs in your browser, with nothing to install.

Also available: Python Examples.

Basics

Input, arithmetic and if/else: the first programs everyone writes.

Numbers

Primes, factorials, Fibonacci and other loops over digits and divisors.

Strings

Reversing, counting and comparing text.

Arrays and algorithms

Searching, sorting and working with arrays.

Patterns and small projects

Nested loops and complete little programs.