Skip to content
Advertisement

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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement