AnyCompiler

Modules and the Standard Library

JavaScript code is often split across multiple files, connected with import and export. This compiler runs a single file at a time, so multi-file imports can't be demonstrated directly here — but the objects that ship built into JavaScript itself work exactly as shown below, no imports needed.

console.log(Math.sqrt(16));
console.log(Math.PI);
console.log(Math.max(3, 7, 2));

console.log(JSON.stringify({ name: "Alice", age: 30 }));
Output
4
3.141592653589793
7
{"name":"Alice","age":30}

Math and JSON are both built into the language — no import needed. JSON.stringify() converts an object into a JSON-formatted string, useful whenever you need to send data somewhere (like an API) that expects text, not a live JavaScript object.

What works here, and what doesn't

This compiler runs each submission in an isolated sandbox with no internet access and no persistent storage between runs. That means JavaScript's built-in objects (Math, JSON, Date, Array, and so on) all work exactly as shown above — but npm packages (anything you'd normally install with npm install) aren't available, since there's no network access to install them, and there's no way to import from a separate local file since only one file is submitted per run.

For learning the language itself, the built-ins cover everything in this tutorial. If you later need an npm package or a multi-file project, that's when you'd move to a local Node.js install or a full project setup.

That's the core of the language. From here, the best next step is practice — pick a small idea and build it using what you've learned across these lessons.

Practice exercise

Print the square root of 81 using Math.sqrt().

← Promises and Async/AwaitMore lessons coming soon