Pavel (Pasha) LechenkoP
Denoβ€’2y agoβ€’
15 replies
Pavel (Pasha) Lechenko

How to restrict global scope in dynamically created function?

I want to dynamically create a function using Function() constructor. How can I restrict access to global scope?

For example, this code:
 console.log(new Function('return Deno.exit(1)')())

should return something like Uncaught ReferenceError: Deno is not defined instead of providing full access to Deno's properties and methods.

Is it even possible?
Was this page helpful?