Online JavaScript Compiler

Write, run, and debug JavaScript code right in the browser—perfect for learning, practice, and quick validation.

JavaScript Code Editor

Output

Standard Output (stdout)

 

Standard Error (stderr)

 

How to Use

  • Write JavaScript code in the left editor (modern ES syntax supported).
  • Click Run Code to execute instantly in a Node.js environment.
  • The right panel displays output and error messages.
  • The green area shows standard output (for example, console.log).
  • The red area highlights runtime errors and warnings.
  • Execution details include the exit code and runtime status.
  • Shortcut: Ctrl+Enter (use Cmd+Enter on macOS).

JavaScript Basics

Hello World:

console.log('Hello, JavaScript!');

Common Types:

  • number / string / boolean / null / undefined
  • object (including arrays []), function, symbol, bigint
  • Declare variables with const / let (block scope; avoid issues caused by var)

Control Flow

Conditionals and Loops:

const n = 5;
if (n % 2 === 0) {
  console.log('even');
} else {
  console.log('odd');
}
for (let i = 0; i < 3; i++) {
  console.log(i);
}

Functions and Arrays

Example:

function add(a, b) { return a + b; }
const nums = [3, 7, 1, 9, 4];
console.log(add(2, 3));
console.log(Math.max(...nums));

Sample Programs (click Run above)

1. Recursive Factorial

function factorial(n) {
  return n <= 1 ? 1 : n * factorial(n - 1);
}
console.log('5! =', factorial(5));

2. Array Maximum

const nums = [3, 7, 1, 9, 4];
console.log('Maximum:', Math.max(...nums));