Dot Notation and Square Bracket Notation in JavaScript

In JavaScript, everything is an object. Put simply, this means that any variable can have properties which are other objects. There are two different syntaxes for accessing properties which this article explains and compares.

This example is destined to be sent to a PHP script and uses the
standard PHP method to indicate that there are multiple controls with
the same name. This requires the use of square brackets in the name of
the control, so dot notation can't reference the controls.

Example with errors:

var inputs = myForm.foo[];

Square bracket notation, on the other hand, allows:

var inputs = myForm["foo[]"];

Since the square brackets are part of a string, their special
meaning doesn't apply.

The second advantage of square bracket notation is when dealing with
variable property names.