console~JS for Web

The console object provides access to the browser console (eg Firefox's Web Console). It works differently on different browsers. The
Console object can be accessed in any global object, such as Window, WorkerGlobalScope and special definitions provided by the property workbench.
It is defined by the browser as Window.console, and can also be called simply by console.
Can print a single object or multiple objects (with , interval)

formatted print

The following characters can be used to perform parameter substitution when passed to the console method.
%o prints javascript objects, which can be integers, strings and JSON data
%d or %i prints integers
%s prints strings
%f prints floating point numbers

for (var i=0; i<5; i++) {
  console.log("Hello, %s. You've called me %d times.", "Bob", i+1);
}
console.log("I want to print a number:%d","string")    //I want to print a number:NaN

Use "%c" to define styles for print content

console.log("%cMy stylish message", "color: red; font-style: italic");

Console.assert()

Determine whether the first parameter is true, if false, throw an exception and output the corresponding information on the console.

Console.clear()

Clear the console.

Console.count()

The number of calls is recorded with the parameter as the identifier, and the identifier and the number of calls are printed on the console during the call.

Console.error()

Print an error message. For usage, see string substitution.

Console.group()

Print the tree structure, with the groupCollapsed and groupEnd methods;

console.log("This is the outer level");
console.group();
console.log("Level 2");
console.group();
console.log("Level 3");
console.warn("More of level 3");
console.groupEnd();
console.log("Back to level 2");
console.groupEnd();
console.debug("Back to the outer level");

Console.groupCollapsed()

Create a new inline group. The usage method is the same as group, the difference is that the content printed by groupCollapsed is collapsed by default.

Console.groupEnd()

end the current tree

Console.info()

Print the information starting with the exclamation mark character, the usage method is the same as log

Console.log()

To print a string, use a method similar to C's printf format output, please refer to string substitution .

Console.profile()

The first parameter can be used as an identifier to start the data collection of the javascript execution process. Similar to the chrome console option to open Profiles, please refer to chrome profiles for details.

Console.table()

Print the data as a table. Console.table [en-US]

Console.time()

A timer that accepts a parameter as an identifier.

console.time("answer time");    //answer time: timer started
alert("Click to continue");
console.timeEnd("answer time");    //answer time:998ms

It should be noted that when you count the number of network requests, the header and response body requests are separate, in other words, the number of response.header+response.body = the number of console.time statistics

Console.timeEnd ()

Accepts a parameter as an identifier to end a specific timer.

Console.trace()

Print stack trace.
Print the function stack currently executed by Console.trace

Console.warn()

Print a warning message, use method can refer to string substitution.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324664225&siteId=291194637