Skip to content
Mage spell

JavaScript

Ranks 1-3

The mage's Blink of languages: by the time you look for it, it is already running somewhere near you. Every browser executes it, and with Node the servers do too.

Wears the Classic spell Blink.

Coming from Python: Functions, collections, and control flow arrive with you almost unchanged. New school: strict equality, values that change type silently, and asynchronous code (promises, then async/await).

Advertisement

Summoning the language

Rank 1

First summoning

Press F12 in any browser, open the Console tab, and type: you are now writing JavaScript with zero installs. Or install Node and put the incantation in a file named hello.js, run it with node. const does not come back; let does; arrows make small functions in one line.

const name = "Chromie";
const shout = (s) => s.toUpperCase() + "!";
console.log(`${shout(name)} ready`);
Rank 2

The temper

Three habits keep you safe: compare with === always, check what a value actually is before using it, and treat network work as asynchronous. await only works inside async functions; a promise forgotten is a result lost.

const res = await fetch("/api/health");
const data = await res.json();
document.querySelector("#status").textContent = data.ok ? "alive" : "dead";
Rank 3

First real chore

Build a to-do page in one HTML file: an input, a button, a list, and the browser's own storage so the list survives a reload. That single exercise touches the document, events, JSON, and state, which is most of frontend work in miniature.

localStorage.setItem("todos", JSON.stringify(todos));
// on load:
const todos = JSON.parse(localStorage.getItem("todos") || "[]");
Back to the grimoireThe Programmer's GrimoirePython, the eight ranks, and every second spell.