Skip to content

Instantly share code, notes, and snippets.

@gornostay25
Last active Aug 31, 2021
Embed
What would you like to do?
Run jscode from string in sandbox
function sandboxcode(s) {
function construct(c, a) {
function F(){return c.apply(this, a)}
F.prototype = c.prototype;
return new F()
}
let g = ["Function","globalThis","eval"]
for (let i in globalThis){g.push(i)}
g.push(s);
return construct(Function, g).apply({});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment