In Javascript, all keys in a property are strings, right? So, in other word,
this code:
var object = {
car: 'tesla'
};
and this code are same:
var object = {
'car': 'tesla'
};
But why is it so that I can access the key car
using : object["car"]
but not using this: object[car]
In other words, why do I need to put the key named car
around quotes if the key named car
has already been turned into a string?
I read this thread but couldn't manage to get a clear answer on this particular issue. Hope someone helps.