Before anything else you need a fast loop of writing a line, running it and seeing the result.
JavaScript runs wherever there is a JavaScript engine: V8 in Chrome, Edge and Node.js, SpiderMonkey in Firefox, JavaScriptCore in Safari and Bun. The language itself is standardised as ECMAScript; browsers add web APIs such as the DOM, and server runtimes add file and network APIs.
The quickest place to experiment is the browser's DevTools console (F12, then the Console tab): type an expression, press Enter, see its value. For a real page, put the code in its own file and load it with a script tag:
<script type="module" src="app.js"></script>type="module" makes the file an ES module: it is deferred until the HTML has been parsed, runs in strict mode and can use import. For a classic script, add defer so it does not block parsing.
On the command line, install Node.js and run node app.js, or just node for an interactive prompt (a REPL).
A program is a sequence of statements. Semicolons end statements; the engine inserts missing ones (automatic semicolon insertion), but most teams either always write them or use a formatter such as Prettier to keep things consistent. Comments are // to end of line or /* block */.
console.log() is your print statement in every environment, and console.table() and console.error() are handy variations.
Example
// app.js — run with: node app.js
console.log("Hello, JavaScript!");
const year = 2025;
console.log(`ECMAScript ${year}`); // ECMAScript 2025
/* console.table prints arrays of objects nicely */
console.table([
{ tool: "node", runs: "server" },
{ tool: "browser", runs: "client" },
]);Remember
- Use the DevTools console or the Node REPL to try ideas instantly
- Load page scripts with
type="module"(ordefer) so they don't block HTML parsing console.logworks in every JavaScript environment
Watch out for
- Putting a plain
<script src>in the<head>withoutdefer: it blocks parsing and runs before the elements it needs exist.