user2879303
user2879303

Reputation:

Why does VS Code's JavaScript syntax highlighting differ when using 'var'?

As you can see below, in some instances it highlights green, in others it is white. Does it have to do with the difference between regular function expressions, and those which are immediately invoked?

I have noticed this effect with the majority of color themes available in Visual Studio Code.

enter image description here

Upvotes: 1

Views: 2107

Answers (1)

Quentin
Quentin

Reputation: 944321

Identifiers with names which begin with capital letters are conventionally reserved for constructor functions / classes.

This is what you are using them for. Your syntax highlighter is distinguishing based on the type of value assigned to them.

screenshot

Upvotes: 6

Related Questions