Pavel (Pasha) Lechenko
Pavel (Pasha) Lechenko
DDeno
Created by Pavel (Pasha) Lechenko on 2/12/2024 in #help
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)')())
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?
16 replies