Reputation: 105
Just a though experiment, say I decided to prevent eval()
from being run in my node application, and I ran added something like:
global['eval'] = function(args){ this.console.log(`eval attempted: ${args}`); }
Is there any way to restore eval without restarting the application?
Upvotes: 0
Views: 102
Reputation: 85132
If you save a reference to the function, yes.
const originalEval = global.eval;
global.eval = function(args){ this.console.log(`eval attempted: ${args}`);}
function restore() {
global.eval = originalEval;
}
Upvotes: 4