javascript - How to implement a cross browser console.log functionality -
this question has answer here:
is there cross browser way of implementing console.log functionality, official supported browser @ 1 of client still ie7/ie8.
as development tested firefox debugging capabilities, come across issues on release obscure flow still left un commented console.log statements doesn't fly ie
looking kind of, if use elegant way, love learn.
function log(msg){ if(ie) alert(msg) else console.log(msg) }
here option:
if (typeof console === "undefined" || typeof console.log === "undefined") { console = {}; console.log = function(msg) { alert(msg); }; }
edit: noted others, should make sure console.log doesn't end in production code.
Comments
Post a Comment