SandboxJS
SandboxJS copied to clipboard
Error: `arguments` is undefined
This code doesn't currently work in SandboxJS (you can try it quick on the dev tools in https://nyariv.github.io/SandboxJS/):
const sandbox = new Sandbox();
const code = `
function test() {
console.log(arguments); // Uncaught ReferenceError: arguments is not defined
}
test(1, 2, 3);
`;
const exec = sandbox.compile(code);
exec(scope).run();
However in normal JS the content code should work:
function test() {
console.log(arguments); // OK, prints an Arguments object
}
test(1, 2, 3);
This is not supported by design, because it could be used to pollute a scope wrapping a piece of untrusted code.