JSLint -Tolerate Ineffective Subscription?

I read the JSlint Options Documentation to understand each of the available options and stumbled upon the fact that I do not quite understand and cannot find any useful information about this elsewhere.

sub - Assume inefficient subpitting

true if the index notation can be used for expressions that are more expressed in dotted notation.

Can anyone shed more light on what this means?

thanks

+4
source share
2 answers

JavaScript objects can be accessed using a descriptor (square bracket):

o.foo o['foo'] 

... This is the same. A square bracket is necessary to access members whose names cannot be used in dotted notation:

 o['hello!'] 

or to access members from a dynamic name:

 var name= issomething? 'foo' : 'bar'; o[name] 

But for simple o['foo'] you do not need it. The o.foo form is o.foo easier to read, so she thinks it's best to use it. Some programmers coming from other languages ​​may prefer to use square brackets for objects that use β€œas a match, not as,” but anyway for JS.

(JSlint claims that the shape of the square bracket is also β€œless efficient,” but if that is the case, the difference is tiny and really not worth the worry.)

+7
source

See here . It looks like the notation in the subscript does:

 document.forms['myformname']; 

instead

 document.forms.myformname; 
+2
source

Source: https://habr.com/ru/post/1304172/


All Articles