How do you "add" an argument to a function call that you don't call directly? Specifically, I have
(function(){
//I have the context of `that` here
var oldLog = console.log;
console.log = function (message) {
//I want the context of `that` over here too
oldLog.apply(console, arguments);
};
})(that);
I'm trying to do this thing where i'm hijacking window
's console as done in the accepted answer as shown here: Capturing javascript console.log?
Because console.log
has to get called with the window.console
's context (since i'm getting the log message from there), I don't have control over how it gets called and the arguments's it gets passed. How do I add that
into the argument list so that I can have that
whenconsole.log
gets called.
TLDR; how do call a function with modified argument list but with same context.