Re:Schrödinger’s Tcl – Values that differ if you look at them
by Darkenetor on Sunday September 17, 2017 @09:11PM
(#15272693)
Reimplementing whole classes wouldn't have been a problem, just replace the original ones with a proxy to a copy.
Luckily console.log calls are actually excluded from the callers stack, so the only way is to change console itself. Just as evil if you also intercept console methods logging and return the original ones, but less of a mess at least.
Like overriding a built-in type and getting function.caller into valueOf(). As far as I can tell, JS doesn't let you just tweak valueOf(), you would have to re-implement all of, for example, the String class.