A chance, open Baidu when pressed the F12, and then see the console inside the output of Baidu recruitment ads, feeling pretty handsome, and then have this blog.
Since you can do this in the console output information, then debug JS after the time can not save a lot of trouble! Avoid fraught, intentionally using the for (var i in console) to view the console support for the various browser consoles,
The results are as follows:
IE 11 Console
Log, info, warn, error, Debug, Assert, Time, Timeend, group, groupcollapsed, GroupEnd, Trace, clear, dir, di Rxml, Count, Countreset, CD, select, Profile, Profileend
Firebug Console
Log, debug, info, Warn, exception, Assert, dir, Dirxml, Trace, group, groupcollapsed, GroupEnd, profile, Prof Ileend, Count, clear, Time, timeend, timeStamp, table, error
Chrome Console
Memory, _COMMANDLINEAPI, debug, error, info, log, warn, dir, dirxml, table, Trace, Assert, Count, Marktimelin E, profiles, Profileend, time, Timeend, TimeStamp, Timeline, timelineend, group, groupcollapsed, GroupEnd, clear
You can see that I tested the browser on the log, info, warn, error, debug five basic methods are supported, note that I use IE 11, the other version I did not test, and Firefox itself is not with the console, the need to load Firebug plug-ins and And start it, can console, otherwise is JS error. In order to use more convenient, you can encapsulate it, to determine the browser support for the console, do not support the use of the original alert or other methods.
Simple usage:
Console.log ("Log Information");
Console.info ("General Information");
Console.debug ("Debugging Information");
Console.warn ("warning hint");
Console.error ("error hint");
Format output:
Console.log ("%d years%d months%d days", 2014, 5, 20);//date format output
Console.log ('%c has color output information ', ' Color:white; Background-color: #0055CC ');//Format output
Output variables:
var who= ' you ';
Console.log (' Output variable We support ', you)/Read variable
Output array:
var arr = [1, 2, 3, 4, 5];
Console.log (' array: ', arr);//output array
The above use of JS console object, in the console printing mode information Test JS implementation is small set to share all the content, hope to give you a reference, but also hope that we support cloud habitat community.