Dot notation cannot work with a variable holding the name of the property. If you are using a variable to say what property you are accessing, bracket notation is mandatory.
When you say “variable holding the name of a property” you mean in this case either ID or PROP?
And sorry but just to clarify, why is this example ok then?
This helped alot thank you. So I can only recall keys assigned through variables via bracket recall.
So am I correct in saying when :
function updateRecords(records, id, prop, value)
occured it created the variables id, prop, value and because this was created then the only way to recall was via bracket notation?
Thanks, and just one last question , is this an easy mistake to make for a beginner or was this distinction meant to be easy enough for me to spot the first time by myself? I felt stupid I couldn’t figure it out at first.
No, there’s so much stuff to learn that we can’t possibly be expected to understand or remember everything. I think the dot/bracket distinction is explained somewhere in the objects part of the Javascript curriculum, but I can’t remember where to be honest.
You should always feel completely free to ask questions about anything which you don’t understand - that’s what this community is here for!