Playground
Write or paste any JavaScript and press Run (or ⌘↩). It runs in your browser, offline too, and prints the way Node does. What you type stays on this device. Every example in the chapters has the same Run and Edit buttons.
// Your playground: write or paste any JavaScript, then press Run (or ⌘↩).
// It runs in your browser and prints the way Node does. What you type is kept on this device.
const nums = [3, 1, 2];
console.log(nums.toSorted((a, b) => a - b), nums);
const user = { name: "Rohit", skills: ["JS", "TS"], address: { city: "Pune" } };
console.log(user);
setTimeout(() => console.log("3. a timer (macrotask)"), 0);
Promise.resolve().then(() => console.log("2. a promise callback (microtask)"));
console.log("1. plain code first");Browser only: Node’s own modules (fs, http, process) aren’t here. An endless loop is stopped after 30 seconds, or press Stop.