One of my faviourite mistakes in Javascript is to forget to define variables I am using locally in a function. As you all know, due to scope, this is not always an error.
Is there any way in Visual Studio Code to highlight variables that are not defined in the function?
For example, say I have the function:
function MyFunction(argument1){ /* Note: not argument5 */
var i; /* Note: not j */
var arr1 = []; /* Note: not arr2 */
... /*Exciting code in between */
len = 7;
for(j=0;j<len;j++){
arr2[j] = "Wibble" + argument5;
}
}
I want len
, j
, arr2
and argument5
all to be highlighted in some way to show they are not defined locally in the function.
Enable JS/TS › Implicit Project Config: Check JS
in vscode settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With