jquery - rewriting console.log to $('body').append -


i got paul irish,

window.log = function(){   if(this.console){     console.log( array.prototype.slice.call(arguments) );   } }; 

q: displaying objects , arrays on page instead of console, how can rewritten use $('body').append instead of console.log?

window.log = function() {     $(document.body).append(json.stringify(array().slice.call(arguments))); }; 

this render strings, arrays , object literals

and amended 1 stop [] brackets appearing , add br tag if call multiple arguments br each argument.

window.log = function() {   $.each(arguments, function(i, a) {     $(document.body).append('<br/>' + json.stringify(a));   }); }; 

Comments