EDIT
Take a look at the comments that you will see that for css properties, key notation is incompatible with a number of properties. Using the camel key symbol is therefore the current way
obj.style-attr // would become obj["styleAttr"]
Use notation, not dot
style["text-align"]
All arrays in js are objects, and all objects are just associative arrays, which means that you can refer to a place in an object the same way you refer to a key in an array.
arr[0]
or object
obj["method"] == obj.method
a couple of things to remember when accessing properties this way
they are computed to use strings unless you are doing something with a counter or using dynamic method names.
this means that obj [method] will give you an undefined error while obj ["method"] will not
You should use this notation if you use characters that are not allowed in js variables.
This regex pretty much sums it up
[a-zA-Z_$][0-9a-zA-Z_$]*
austinbv Aug 19 2018-11-11T00: 00Z
source share