$log first checks to see if the browser supports console.log (e.g. IE 8). This prevents errors in IE 8. Note: this does not mean that it will write anything in IE 8, it just means that it will not throw an error.
In addition, it also allows you to decorate and layout $log for expansion and testing, if you are so inclined. You could, for example, decorate it to enter an array to support IE 8.
Bonus feature: if you pass it a JavaScript Error instance, it will try to format it nicely. You can find this out by reading the source code .
EDIT: "It's not that IE 8 does not support console.log. It just does not create a console object until the dev tools are open." See comments below for more details.
Steve Klösters Jun 12 '14 at 13:40 2014-06-12 13:40
source share