Introduction
This guide has been updated for 2025.
JavaScript is the language that makes the web do things. Click a button, load content without refreshing, validate a form before it gets sent — that’s all JavaScript. It’s not just for making things pretty; it’s the reason modern websites feel fast, responsive, and alive.
But JavaScript isn’t just for browsers anymore. These days, it’s used on servers, in desktop apps, even in smart TVs and robots. And while it’s powerful, learning it — especially the right way — can be confusing when you’re surrounded by outdated tutorials and mixed advice.
This guide cuts through the noise. You’ll get the real story on how JavaScript works, how it fits into the web, and why it behaves the way it does. Not a surface-level overview, not a crash course — a proper, useful foundation.
What is JavaScript?
At its core, JavaScript is a programming language designed to run in the browser. It was built in 1995, rushed out in under two weeks by a guy named Brendan Eich, and somehow — 30 years later — it’s one of the most-used languages on the planet.
It was originally meant to make web pages interactive. Think: popups, form checks, dropdowns. But it didn’t stop there. Over the years, JavaScript evolved. New tools, better syntax, entire frameworks were built on top of it. And now it powers everything from tiny portfolio sites to entire apps like Gmail, Spotify, and Netflix.
The reason it’s everywhere? It runs in the browser. No extra setup. Just open DevTools and go.
How JavaScript Plays with HTML
JavaScript lives inside your HTML files. You use a <script>
tag to drop in code or link to an external file. Here’s the most basic setup:
<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
<script>
console.log("The page loaded.");
</script>
</head>
<body>
<h1>Hello there</h1>
</body>
</html>
You can also separate things out and keep your JavaScript in its own file:
<script src="main.js"></script>
Where you put the <script>
tag matters. If it’s in the <head>
, the browser may try to run your JavaScript before the page content exists. That’s why people often put it just before the closing </body>
tag — or add defer
so it waits until the page is ready.
A Quick Note on Versions
JavaScript is standardized under something called ECMAScript (you’ll see it written as ES6, ES2015, etc.). Every year, new features get added to the language. That’s why some tutorials are confusing — they mix old and new styles without telling you what’s what.
For example:
- ES6 (2015) gave us
let
,const
, arrow functions, template strings, and classes - ES2017 added
async/await
, which made handling promises way easier - More recent updates added optional chaining (
?.
) and nullish coalescing (??
)
Don’t stress about memorizing versions. Just know that modern JavaScript is a lot nicer to write than it used to be — and that’s what we’re focusing on here.
The Basics
JavaScript is what developers call a “high-level, dynamic language.” What that means is: you don’t worry about things like memory or types too much, and you can write code quickly and flexibly.
Here’s the classic first step:
console.log("Hello, world!");
That prints a message to the browser’s console. You’ll be using that console a lot when testing and debugging your code.
You can declare variables like this:
let name = "Sam";
const age = 30;
The key difference? let
can change. const
can’t.
JavaScript is also loosely typed. That means you can do this:
let thing = 42;
thing = "now it’s a string";
It’s flexible — but also easy to make weird mistakes if you’re not paying attention.
Why JavaScript Feels Different
A few things make JavaScript stand out:
- It runs in the browser, live. You write it, and it works instantly in the user’s browser.
- It lets you mess with the DOM — the structure of the webpage — on the fly. You can change text, hide things, move stuff around, all in real time.
- It has something called closures, which let functions remember variables even after the outer function is done running. Sounds weird? It is. But once you get it, it’s powerful.
Supersets (aka JavaScript with Extra Features)
Sometimes plain JavaScript isn’t enough, especially in big projects. That’s where supersets come in.
- TypeScript: Adds types, catches bugs early, and plays nice with modern tooling.
- CoffeeScript: A cleaner syntax that compiles to JavaScript. Popular a decade ago, not so much now.
- Dart: Used by Google in Flutter. Feels like JavaScript with training wheels and a twist.
If you’re learning, skip these for now. Focus on understanding regular JavaScript first.
Where JavaScript Runs
You already know it runs in the browser. But that’s not the only place:
- Node.js: Lets you run JavaScript on a server. Build APIs, command-line tools, even full web apps.
- Electron: Build desktop apps with JavaScript, HTML, and CSS. Think VS Code or Slack.
- React Native: Use JavaScript to write mobile apps.
Basically, once you know JavaScript, you can build almost anything.
Wrapping It Up
JavaScript started as a quick hack to make web pages feel interactive. Now it’s the most-used language on the internet. It’s fast, flexible, and — once you understand it — actually fun to write.
This guide is just the starting point. We’re not here to throw random features at you. We’re building your skillset piece by piece, the same way you’d learn on the job.
Part of the Series
This is part of the Ultimate JavaScript Tutorial series. Up next: writing real code, understanding variables, and dodging the common mistakes almost every beginner makes.
🤔 What do you think?