Glitch in color of property

When I attach a property to a variable it’s dark blue and shows an explanation of what it does.
image

but when I attach a new property to the variable but not to the original variable, light blue without explanation. and it works still.

image

How do I fix this? is it just my vscode?

Well an array of childNodes wont have an array of childNodes themselves. But I assume you mean if you set the variable to the querySelector return

My instinctual response is that its because Javascript isn’t strongly typed. VSCode knows that when you call .querySelector on something, it will return an object of type Element (or null), and so it can tell you from the follow-on what properties and methods that return has. Once it’s been assigned to a variable, it’s just a prototype object. You could have manipulated that object into being anything, redefining methods or properties of the object, so it can’t determine for sure what it is.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.