Skip to main content
Start an interactive Read-Eval-Print Loop (REPL) for executing JavaScript code.

Usage

ant
Launch the REPL by running ant without any arguments.

Features

  • Interactive Evaluation: Execute JavaScript expressions and see results immediately
  • History Support: Navigate previous commands with arrow keys
  • Multiline Input: Automatic detection of incomplete expressions
  • Command History: Persistent history saved to ~/.ant/repl_history
  • Color Output: Syntax-highlighted results
  • Auto-completion: Context-aware completions

REPL Commands

Special dot commands are available in the REPL:
.help
command
Show help message with available commands.
.exit
command
Exit the REPL.
.load <filename>
command
Load JavaScript from a file into the REPL session.
.save <filename>
command
Save all evaluated commands in this REPL session to a file.
.stats
command
Show memory statistics.

Examples

Basic Usage

$ ant
Welcome to Ant JavaScript v1.0.0
Type ".help" for more information.
> 2 + 2
4
> const greeting = "Hello, World!"
undefined
> greeting
"Hello, World!"

Multiline Input

> function add(a, b) {
|   return a + b;
| }
undefined
> add(5, 3)
8

Using REPL Commands

> .load script.js
> .save session.js
Session saved to session.js
> .stats
{ heapSize: 1024, used: 512 }
> .exit

Keyboard Shortcuts

  • Ctrl+C: Abort current expression (press twice to exit)
  • Ctrl+D: Exit the REPL
  • Up/Down Arrow: Navigate command history
  • Enter: Execute current line or continue multiline

Lexical Declarations

The REPL tracks let, const, and class declarations to prevent redeclaration errors:
> let x = 10
undefined
> let x = 20
Error: Identifier 'x' has already been declared

Build docs developers (and LLMs) love