Debugging Javascript with Console

A quick review. Console.log() //how to print a log statement console.log('That thing you expected to happen is now happening!'); //how to break production sites in internet explorer console.log('anything'); //how to log safer function l(str){if(window.console&&console.log){console.log(str);}} l('I can forget this in my code base without breaking anything!'); Console.trace() //how to figure out what's calling what console.trace(); //console.trace example: function a() { console.trace(); } function b() { a(); } function c() { b(); } function d() { b(); } if (Math.random() < 0.5) { c(); } else { d(); } If you copy and paste that console.trace example into the Chrome Console you’ll get a full stack trace like this one: ...

July 9, 2013 · 1 min · Paul