3

A coworker is running JSLint on our code and fixing the issues that come up. One change he made was to go from this:

document.getElementById(control["value1"]);

to this:

document.getElementById(control.value1);

Is it JSLint's preference to use the dot notation over array brackets? My understanding from here is that the brackets are a bit more flexible, and I wondered what the best practices from the field were.

Kara
  • 5,996
  • 16
  • 49
  • 56
larryq
  • 14,893
  • 36
  • 116
  • 184

1 Answers1

3

Best practice is to use . notation unless you actually need to pass a variable.

This looks more normal, and also allows the JITter to do more intelligent things.

SLaks
  • 837,282
  • 173
  • 1,862
  • 1,933