Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 748 Bytes

File metadata and controls

27 lines (21 loc) · 748 Bytes
title description url layout
Intereactive JavaScript REPL
Learn how to provide an interactive JavaScript REPL in a sandbox.
/examples/sandboxes_javascript_repl/
sandbox-example.tsx

The sandbox.repl() method can be used to provide an interactive JavaScript REPL in a sandbox.

This example shows how to start a JavaScript REPL in a sandbox and execute code interactively.

import { Sandbox } from "@deno/sandbox";

await using sandbox = await Sandbox.create();

// Start a JavaScript REPL
const repl = await sandbox.repl();

// Execute code interactively, maintaining state
await repl.eval("const x = 42;");
await repl.eval("const y = 8;");
const result = await repl.eval("x + y");
console.log("result:", result); // 50