// Basic Usage
console.log ( 'The most common use of \ n newline');
. Console error ( 'output an error message will be displayed in red');
. Console The warn ( 'print a warning message will be displayed in yellow');
. Console info ( 'Print general information ');
. console Clear (); // Clear display console above
// Advanced Usage
console.assert ( false , 'it is false determination information displayed'); //console.assert(bool,"info ") is false if bool info printed out or not print
console.table ([[ 'Chinese', ' U.S. '], [' good ']]); // passed objects displayed in tabular form or an array of
function Fn () {console.trace ();} // call chain Fn2 print () call fn1 (), fn1 () call Fn ()
function Fn1 () {Fn ();}
function Fn2 ( ) {Fn1 ();}
Fn2 ();
// formatted output
-
Format flag console.log supported are:
-
% S placeholder
-
Or an integer of% d% i
-
% F float
-
% O% O object Object
-
% C css styles
the console.log ( 'D%% +% D = D', l, 2,3 );
// % O% O when the node is not the same print dom the console.log ( '% O' , the document.body); Console .log ( '% O' , the document.body);
// behind% C content, increases css style
@ attachment: console.log output hyperlink is automatically recognized and adding gray font color and underline style, and this can not be covered with C%
the console.log ( 'C 456 123%', 'font-size: 36px; Color: Red;' );
the console.log ( '123. 4% C http://www.google.com C 789% 56 is', 'font-size: 20px; Color: # ff8400;', 'font-size: 12px; Color: # 000' );
// use css style load picture // not directly setting the width and height style, line-height height of the image, and then transferred padding
console.log('%c ','background-image:url("http://iyeslogo.orbrand.com/150902Google/005.gif");background-size:120% 120%;background-repeat:no-repeat;background-position:center center;line-height:60px;padding:30px 120px;');
// Advanced Usage
// timer, in milliseconds console.time (); for ( var I = 0; I <100000; I ++ ) { var J = I * I; } console.timeEnd (); // statistical code number or function is called Ci var FN_ = function () {console.count ( 'Hello World' );} for ( var I = 0; I <. 5; I ++ ) { FN_ (); } // Check memory usage, is a property, without brackets // console.memory; // in the browser developer tool // output packet can be nested console.group ( 'packet. 1' ); the console.log ( 'language' ); console.log ( 'mathematical' ); console.group ( 'other subjects' ); console.log ( 'chemical' ); console.log ( 'geography' ); console.log ( 'history' ); console.groupEnd ( 'other subjects' ); console.groupEnd ( 'packet 1');