Home > Web Front-end > JS Tutorial > Introduction to the console.trace() function in JavaScript_javascript skills

Introduction to the console.trace() function in JavaScript_javascript skills

WBOY
Release: 2016-05-16 16:23:44
Original
1586 people have browsed it

When debugging a JavaScript program, sometimes you need to print the stack information of function calls. This can be achieved by using console.trace(). Take the following code as an example:

Copy code The code is as follows:

function doTask(){
doSubTask(1000,10000);
}

function doSubTask(countX,countY){
for(var i=0;i for(var j=0;j }
console.trace();
}

doTask();

Insert a line of console.trace() statement at the end of the execution of the doSubTask() function, which will print the function call stack information there in the debugging console. For example, in the Firebug console it looks like this:

In the Firebug console, console.trace() will not only print function call stack information, but also display the values ​​of each parameter in the function call.

Browser support

Console.trace(), like console.log(), is better supported by browsers with debugging tools. All major browsers support this function.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template