Partilhar via


F12 developer tools console API methods

Developers regularly use the JavaScript Console for status and error logging. In Internet Explorer 11, use new methods to add timing markers to your code, automate inspection, and group your console output.

Timing methods

Set named timers to begin and end at different points in your code. Wrap functions, processes, or individual lines of code for precision timing information.

Method Description
console.time(name) Starts a timer. Track timers by using a different name for each as the optional parameter. If you don't specify a name, "default" will be used.
console.timeEnd(name) Ends a timer and sends the result to the console. If you don't specify a name, "default" will be used.

 

Inspection methods

Use these methods to dig deeper into XML objects and view stack traces.

Method Description
console.debug() An alias for console.log(). Added to improve compatibility with legacy code.
console.dirxml(XML node) Sends an XML node object to the console as an expandable tree.
console.trace() Sends a stack trace to the console from wherever it's called in code.

 

Grouping methods

The grouping methods organize your console output into groups you can expand or collapse. Groups can be nested within other groups.

Method Description
console.group(groupTitle) Begins a group with the title in the parameter and puts subsequent console messages in it. Groups appear expanded, but can be collapsed. If no title is provided as a parameter, the group is assigned a title of "".
console.groupCollapsed(groupTitle) Begins a group with the title in the parameter and puts subsequent console messages in it. Groups appear collapsed, but can be expanded. If no title is provided as a parameter, the group is assigned a title of "".
console.groupEnd() Closes the most recently opened group.

 

Count method

This method creates a named counter in the console and increments it each time it's called.

Method Description
console.count(title) Logs a counter to the console the first time it's called with a title parameter. A title's counter is incremented by 1 each time console.count is called with that title. If no title is provided as a parameter, a counter is assigned to a title of "".

 

Console debugging API

What's new in F12 Tools