Skip to main content

评估 JavaScript

Deno Sandboxes provide a sandboxed environment for evaluating JavaScript code. This is useful for evaluating code that is not trusted or for testing code that is not safe to run in the main runtime.

你可以使用 eval 函数在沙箱中评估 JavaScript 代码。

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

await using sandbox = await Sandbox.create();

const result = await sandbox.eval(`
  const a = 1;
  const b = 2;
  a + b;
`);
console.log("result:", result);

For more information about Sandboxes, see the Sandboxes documentation.

你找到了你需要的东西吗?

编辑此页面
隐私政策