skip to Main Content

I want VScode to inform where a defined function is being called from.

file utils.js

function counter(){
 console.log('counter');
}
export default counter;

file index.js:

import counter from './utils';

counter();

I want to know in counter function definition in utils.js that it is being used at index.js

if the function counter is called in different files I want to get the information about where the function is being used | called from.

3

Answers


  1. Chosen as BEST ANSWER

    Thanks for the answers. I found that VScode has an inbuilt reference locater. Just right-click the function and select the option find all references, and VScode will locate all the references to that functions Shortcut: Alt + Shift + F12


  2. enter image description here

    Explain: Browser log should show the whole callstack where the error should throw

    Login or Signup to reply.
  3. As stated by @hUwUtao, the callstack has the information about the callers of your counter() function when it is executing. If you want to find references without executing, VS Code can do this by right-clicking the function, then selecting Go to References, as seen in the following screenshot.

    VS Code Option Go to References

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search