Hello, JavaScript
What JavaScript is, where it runs, and your first programs in the browser and Node.
What is JavaScript?
JavaScript is the language of the web. It was created in 1995 by Brendan Eich at Netscape — famously written in just 10 days — to make web pages interactive. Today it has grown into a general-purpose language that runs almost everywhere: in every web browser, on servers (via Node.js, Deno, and Bun), in mobile apps (React Native), on desktops (Electron), in databases (MongoDB), and at the edge (Cloudflare Workers, Vercel).
JavaScript is sometimes confused with Java. They have nothing to do with each other — JavaScript was named to ride the marketing wave of Java, and the name stuck. Today the official standard is called ECMAScript (ES), and modern JavaScript is loosely "ES2015 and later".
How JavaScript runs
JavaScript is interpreted (technically, just-in-time compiled by engines like V8 in Chrome and Node.js). You don't compile it to a binary — you ship the source, and the runtime turns it into machine code on the fly. Different runtimes give you different APIs:
- In the browser: you get the DOM (the page's HTML tree), `fetch`, `localStorage`, `setTimeout`, and the rendering engine.
- In Node.js: you get the file system, network sockets, processes — but no DOM or window.
- In edge runtimes: a slimmed-down web-standard environment, optimized for cold starts.
Your first program — in the browser
Open any web page, press F12 to open DevTools, click Console, and type:
console.log("Hello, world!");`console.log` writes a message to the developer console. It is your most-used debugging tool — get comfortable with it.
Your first program — in Node.js
Install Node from nodejs.org (LTS version is fine), then save this as `hello.js` and run it:
node hello.jsconsole.log("Hello from Node!");Statements and semicolons
JavaScript statements end with a semicolon `;`. Technically the language has "automatic semicolon insertion" and you can omit them in most places, but it's safer to just include them. Pick one style and stick with it (most teams use semicolons; the rest use Prettier's no-semicolon style).