Search code examples
javascriptvisual-studio-codestatic-analysis

Search for place where variable is given value


Is there any mechanism within VS Code (including plugins) to search for the place where a variable is given a value? I often search for myvariable = but that doesn't catch things like:

{ myvariable } = ...
[ myvariable ] = ...

function myfunc(myvariable) { }
myfunc(myvalue)

I'm working with JavaScript exclusively.


Solution

  • Not sure this is the right stack exchange for this question, but yes, there is a way to find these. The article on code navigation will help you further. Basically, VS Code has a command "Find references" (for me it's keybind F12 or ctrl+shift+F12 for a "full" version, but I don't know if this is the default) which will show you where a variable/type is declared and used.

    As far as I know, there isn't an easy way to find only the places where a variable gets assigned. But these are included in the references search.