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.
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.
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.
// 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}`);
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.
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.
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".
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.
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.
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.
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.
main.jsjavascriptrequire("readline") or process.stdinconsole.log("Hello from JavaScript!");
const name = "Developer";
console.log(`Welcome, ${name}!`);