tell the order of javascript functions that have been called
I've been using Chrome scripts to identify the order of the Javascript functions that are ru开发者_开发问答nning.
It's a bit overkill for what I'm doing right now as what I only really need is to have a log of the javascript functions that have been called.
What are you guys here using for that purpose?
Thanks for the feedback.
if you want to be cool, and create overhead you can do this.
function callFn( fn ){
console.log( arguments[0].name );
fn.apply(this, Array.prototype.slice.call(arguments,1) );
//Sorry about the second line, it's necessary because of
// shortcomings of JavaScript (for now!)
}
I'm posting this because I thought it was a cool idea, but not very feasible. It is common for people to add something like this where they need to debug code. Depending on your minifying engine, it will automatically remove this sort of code on compilation.
//LOG
console.log( arguments.callee.name );
//LOG
Sometimes I like to put console.log("function name") at the top of each function that I want to track. That will output the string "function name" to the console, which you can see in the Chrome developer tools window.
Try this one: http://eriwen.com/javascript/stacktrace-update/
Javascript stacktrace that works across most browsers.
精彩评论