Internet Explorer and console.log woes

I cannot begin to count the number of hours I have wasted trying to figure out what the hell Internet Explorer is doing. This latest one really threw me for a loop, so I thought I would share what I learned so someone else doesn’t waste the time that I did.

Internet Explorer does not support console.log but you will never know that once you open the Developer Tools!

Internet Explorer 8’s javascript support is less than stellar. Its better than it was, but still far from perfect. If you are like me, you probably develop your apps with a real browser like Chrome, Safari, or perhaps some of  are still using Firefox. Then you run it in IE and hope for the best. So when I finished coding a new release today, everything ran fine in IE so out the door it went.

Sure enough, a few hours later, the client comes back reporting a bug. My javascript was broken but for the life of me I couldn’t find where or why. It turns out that I had gotten lazy and left an unwrapped console.log message in my code. There are a million blogs out there that show you how to safe guard against this for IE  (window.console && console.log && console.log(“foo bar”); ). But I was lazy.

I admit… its partially my fault. But here is why I hate IE – once you open the Developer Tools, console.log is available from that point forward. An end user that has no idea what the Developer Tools are will see code that crashes due to an “Unsupported Object or Property”, essentially a Null Pointer Exception. But as a developer who has used the Developer Tools, everything works fine and dandy. Ugh.

So take heed. Don’t be lazy and leave unchecked console.log messages in your code. If you do, it could cause trouble for your users without you even realizing it.

Like this post? Please share it! Then follow us on Twitter – @thorntech – and sign up for our email list below for future updates.

Get insights on SFTP Gateway, cloud computing and more, in your inbox.

Get smarter about all things tech. Sign up now!

Scroll to Top