I don’t understand what does this sentence mean even though I know how to use dot notation.
Dot notation is what you use when you know the name of the property you’re trying to access ahead of time.
More on this,
…access ahead of time.
Thanks in advance!
(you don’t access ahead of time, you know ahead of time the name of the property you are trying to access)
if you know the name of the property and you use it directly, you can use dot notation, if instead the name of the property is in a variable you can’t use dot notation, but you need bracket notation
obj.nameProp will try to access the property with name of
There are cases in which you can’t use dot notation even knowing exactly the name of the property
for example if the name of the property is
"name Prop", then you absolutely need bracket notation:
Thanks for explanation.
One question, in what kind of condition(s) we need to assign property to a variable?
do you mean the property name?
there are ways to extract the property names from an object, for situations in which you nerd to iterate through the object properties, in that case you will have a variable holding the property names
Now I understand it.