Safe console.log usage in all browsers

/ Published in: JavaScript
Save to your folder(s)

IE doesn't like console.log. This fixes that.

Copy this code and paste it in your HTML
  1. // make it safe to use console.log always
  2. (function(a){function b(){}for(var c="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),d;!!(d=c.pop());){a[d]=a[d]||b;}})
  3. (function(){try{console.log();return window.console;}catch(a){return (window.console={});}}());

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.