Is it possible to use eval()
to evaluate JavaScript code and be certain that that code will not have access to certain objects?
Example:
(function(window, location){ eval('console.log(window, location)'); })()
The above code doesn't seem to have direct access by reference to the window
object because it is undefined
in that scope. However, if another object exists globally and it contains a reference to window
, it would be accessible.
If I add to window, location
any other object or variable that may contain a reference to window
, will the evaluated code ever be capable of referencing the window
object?
I am trying to create a platform where user apps can be uploaded with js files and access to specific APIs will be given in the form of permissions.