Skip to main content
Running ant with no arguments and no piped input opens an interactive Read-Eval-Print Loop (REPL). The REPL is a fast way to experiment with JavaScript, test expressions, explore Ant’s built-in APIs, and debug small snippets without writing a file. Every expression you type is evaluated immediately and the result is printed below it.

Starting the REPL

ant
Ant prints a welcome message and drops you into the prompt:
Welcome to Ant JavaScript v0.1.0
Type .copy [code] to copy, .help for more information.


The prompt indicates the REPL is ready for input. A dimmed | prompt appears when you are inside a multi-line expression.

Evaluating expressions

Type any JavaScript expression and press Enter. Ant evaluates it and prints the result.
1 + 1
2
"hello".toUpperCase()
'HELLO'
❯ [1, 2, 3].map(x => x * 2)
[ 2, 4, 6 ]
typeof globalThis
'object'
Non-undefined results are pretty-printed with color highlighting. undefined results are not printed.

Multi-line input

If you open a parenthesis, bracket, brace, or template literal without closing it, Ant switches to multi-line mode and shows a continuation prompt. Press Enter on an empty line to submit the buffered input.
function add(a, b) {
| return a + b;
| }
undefined
add(3, 4)
7
The REPL tracks bracket depth, string context, and template literals to determine whether input is complete before evaluating.

Special variables

The REPL exposes two special variables that are updated after each evaluation:
VariableValue
_The result of the last evaluated expression
_errorThe last uncaught error
Math.PI * 2
6.283185307179586
_
6.283185307179586

REPL commands

Commands start with a . and are available at the top-level prompt only (not inside multi-line input).
CommandDescription
.helpList all commands and keybindings
.exitExit the REPL
.clearClear the screen
.historyShow command history
.load <file>Load a JavaScript file into the current session
.save <file>Save all evaluated commands in this session to a file
.statsShow memory statistics
.copy [expr]Evaluate an expression and copy its value to the clipboard

Keybindings

KeyAction
Ctrl+DExit (EOF)
Ctrl+CAbort current expression; press twice to exit
Up / DownNavigate history
Left / RightMove backward/forward one character
Home / EndJump to start/end of line
BackspaceDelete character backward
DeleteDelete character under cursor
EnterSubmit input

Syntax highlighting

The REPL highlights your input as you type, using the same syntax rules as Ant’s engine. Keywords, strings, numbers, and identifiers are colored distinctly. Multi-line buffers are highlighted based on the accumulated input so far, keeping the visual context consistent as you type.

Loading an existing file

Use .load to bring a script file into your running REPL session without leaving the prompt:
❯ .load utils.js
All declarations from the file become available in your session. This is useful for loading helper functions you want to call interactively.

Saving your session

Use .save to write every expression you evaluated in the current session to a file:
❯ .save session.js
Session saved to session.js
The REPL stores history across sessions. Your previous commands are available with the Up arrow the next time you open the REPL.