For example:
(function() {
var proxied = window.eval;
window.eval = function() {
return proxied.apply(this, arguments);
};
})()
Maybe I didn't understand the question correctly, but I "override" eval()
by creating a myEval()
function that has the original eval()
inside it and execute addition steps in myEval()
.
function myEval = function(value){
//do your stuff here
//for example
try {
value = eval(value)
} catch (error) {
console.log(error)
value = NaN
}
return value
}