XCODX |

JavaScript Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About JavaScript

JavaScript was created by Brendan Eich at Netscape in 1995 to add interactivity to web pages, and was standardized as ECMAScript (ECMA-262) two years later. It is a dynamically typed, multi-paradigm language built around first-class functions and prototype-based objects; the yearly ECMAScript editions since ES2015 added classes, modules, arrow functions, destructuring, and async/await. Since Node.js appeared in 2009 (Ryan Dahl), the same language also runs outside the browser on servers, build tooling, and command-line programs. Today it is the only language browsers execute natively and powers a large share of back ends too, which keeps it near the top of every developer usage survey. Note that this page runs server-side JavaScript on Node.js, not inside a browser.

Hello World in JavaScript

// Node.js server-side JavaScript
const nums = [1, 2, 3, 4, 5];
const squares = nums.map(n => n * n);
console.log(`squares: ${squares.join(", ")}`);

let total = 0;
for (const n of nums) total += n;
console.log(`sum of ${nums.length} numbers = ${total}`);

When to use JavaScript

JavaScript is the natural choice whenever code must run in a browser, since no other language runs there without being compiled to it, and with Node.js it is a strong default for web back ends, small CLIs, and quick automation. Running the same language on the front end and back end, backed by the large npm registry, keeps a web product in one skill set. It is a poor fit for CPU-bound numeric or systems work, where C, Rust, or Go run faster, and its dynamic typing lets type mistakes reach runtime rather than surface earlier, which is why many large codebases layer TypeScript on top.

Common questions

Which JavaScript runtime runs here, and is this the browser?

It runs on the Node.js build the execution server advertises, and the exact version is shown in the badge next to the language name. This is server-side JavaScript, so there is no browser: no window, document, DOM, or alert(). Use console.log for output.

Can I npm install packages like lodash, express, or axios?

No. There is no npm install and no package.json resolution, so only Node's built-in modules are available, imported with require() or import: fs, path, os, crypto, readline, util, and similar. Any third-party package such as require('express') or require('lodash') fails with "Cannot find module".

How do I read input from stdin in JavaScript?

Use Node's built-in readline module over process.stdin, for example: const rl = require('readline').createInterface({ input: process.stdin }); rl.on('line', line => { console.log(line); });. The browser functions prompt() and alert() do not exist here. Type into the live terminal when a prompt pauses, or paste everything into the Stdin Box up front, and send Ctrl+D to close the stream.

Why don't document, window, or alert() work?

Those are browser globals provided by the DOM, and this sandbox is Node.js, which has no web page attached. Replace alert() with console.log, and remember there is no HTML, canvas, or localStorage to manipulate. Only server-side APIs exist.

Can I fetch data from an API or read and write files?

The sandbox has no network access, so although modern Node exposes a global fetch, requests cannot reach any server and will fail to connect. The built-in fs module does work, but the filesystem starts fresh on every run and is discarded afterward, so nothing you write persists between runs.

Which modern JavaScript features and syntax are supported?

Whatever the shown Node.js version supports, which for current builds includes let and const, arrow functions, template literals, destructuring, spread, async/await, optional chaining, and nullish coalescing. Prefer const and let over var. If a very new proposal does not run, it likely postdates the runtime version in the badge.

How JavaScript runs on XCODX

Sandbox filename
main.js
Entry point
single main source file
Editor grammar
javascript
Reading stdin
require("readline") or process.stdin
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

console.log("Hello from JavaScript!");
const name = "Developer";
console.log(`Welcome, ${name}!`);