Why can't I use crewMember.name?

can you please tell me , what do you mean by :
"[quote=“stetim94, post:3, topic:432921, full:true”]

…for the dot nation (object notation if you like), we must use the same of the property,

I think I am almost getting it but then I am not sure :frowning:


if you want to use the dot notation, you have to use the property name (obj.prop). where prop can’t be a string.


You just gave me the missing piece to really understand it. Thanks! To summarize it for myself: The for … in gives you the solution, not the path. If you want to work with the path, you have to write it out.


Thank you for sharing this resource!! It’s a thing of beauty.

This is a fantastic explanation. I too was confused at first but now understand. The variable declared within for in loop is used to hold the properties value as a string and not the path to the object. :grinning:

Thank you for the great explanation.

That happens because you are not looking for the string ‘crewMember’ but for the value that crewMember stores (it is a variable you declared when defining the for… in loop. So, in order to evaluate a variable you must use bracket notation, otherwise it will look the property exactly as you typed it (and the crewMember property doesn’t exist).

Wow, this helped so much. Great explanation, I was confused as to why my dot notation wasn’t working.

Are there no existing explanations in this topic that cover your question?