Console.log()
Almost everybody using Firebug extension of Firefox is familiar with console object and in common with console.log method, who’s taking an object parameter and dumps it into the Firebug console. It’s perfect for debugging and it’s really useful.The problem is that if you don’t have Firebug installed or it’s disabled the console object is undefined. The same may occur if you’re using other browser. That’s why I decided to make a simple plugin for jQuery with the $.log interface which checks for the console and opera objects and if they don’t exists just alert the message. It’s nothing special.
jQuery log
the code is really simple and small:
(function(jQuery) { /** * log * * write debug errors to the console or * alert them if the browser does not support * the console object * * @public * @param {Object} * @return {Void} */ var log = function( object ) { if ( typeof console == 'object' ) console.log( object ); else if ( typeof opera == 'object' ) opera.postError( object ); else alert(object); } jQuery.fn.log = log; jQuery.log = log; })(jQuery);
Demo page
The demo of the page is here.
Great Job 🙂 nice code
very useful