JavaScript object members can be accessed using dot or subscript (square bracket) notation:
o.foo
o['foo']
...are the same thing. Square bracket notation is necessary for accessing members whose names can't be used in dot notation:
o['hello!']
or for accessing members from a dynamic name:
var name= issomething? 'foo' : 'bar';
o[name]
But for simple o['foo']
you don't need it. Normally the o.foo
form is easier to read so it's considered better practice to use that. Some programmers coming from other languages may prefer to use square brackets for objects being using ‘like a mapping’ rather than ‘like an object’, but it's all the same to JS.
(JSlint is claiming that square bracket form is also “less efficient”, but if so then the difference is minuscule and not really worth bothering about.)