Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find from where a function has been called (function call stack)

I have a function which is being called from several files. Is there a way to determine from which file a function is being invoked by tools like Chrome DevTools?

function turnCoffeIntoCode (args) {
    // logic here
    debugger;
}

With the above, I can see the arguments being passed to the functions thanks to Chrome's developer tools but I cannot find from where the function is being called.

like image 625
Matthew Barbara Avatar asked Aug 06 '26 08:08

Matthew Barbara


1 Answers

You can see the full call stack on the Chrome Developer Tools: https://developers.google.com/web/tools/chrome-devtools/javascript/reference#call-stack

Just add a break point or a debugger; and you will be able to see the call stack and will be able to click and go to different functions in the stack.

And to read more, you can find many questions and answers about the call stack in chrome.

like image 150
Amr Elgarhy Avatar answered Aug 08 '26 20:08

Amr Elgarhy