Can I limit the access of a string-generated function (using the Function constructor) to the parent/global scopes?
For example: the following code, as it is, prints
@Esailija's answer is right. Additionally, I would recommend limiting the number of global variables that you have to protect in the first place. Put anything that you would normally put in the global namespace in an APP scope that you control:
var APP = (function() {
return {
a: 4
};
}());
There's no way to completely limit access to the global scope, but at least this way you only need to protect one object: APP.