I'm reading this part of Eloquent Javascript, and got stuck with the properties.
It said that
Both
value.x
andvalue[x]
access a property on value—but not necessarily the same property.......
Whereas
value.x
fetches the property of value named “x”,value[x]
tries to evaluate the expression x and uses the result as the property name.
(value
is an array and x
is property like .length
in this example.)
What's the difference between value.x
and value[x]
? I don't know how value[x]
evaluate expression.