This is where I’m starting to find static code analysis odd.
Google Closure give me this error
// using dot notation
JSC_INEXISTENT_PROPERTY:
when I use dot notation to access object properties that are dynamically created (i.e. there is no explicit creation of the property )
When I use bracket notation the error goes away but now jshint.com throws an error:
// using bracket notation
['tag'] is better written in dot notation.
I know that these warning/errors are only hints to write better code…but they contradict each other.
Here is the offending line:
vDomTagAdd(bookmark_object.tag);
Related
These are two different warnings. Closure thinks that this property doesn’t exists because it can’t find the point where you create it. I assume that you can somehow tell Closure that this property is dynamic and you are certain it exists.
JSHint simply gives you a stylistic warning that it’s better to use dot-notation unless you absolutely have to use brackets but it doesn’t try to guess if your property is defined.