I attempted capturing the JavaScript console log using the method mentioned here on Stack Overflow. However, I am facing difficulty in retrieving the object along with a text message. Below is the code snippet that I have been working with:
var obj={result:true,type:"text"};
(function(){
var oldLog = console.log;
console.log = function (message) {
alert(message); // The object does not get returned
oldLog.apply(console, arguments);
};
})();
console.log("hi",obj);
What should I replace message
within the alert
line of code to successfully receive the obj
object as well?