I am trying to understand something very basic. If I have an object like this:
var topics = {}
And I do this:
topics[name] = ["chapter 1", "chapter 2", "chapter 3"];
When I log this object, I don't see the name attribute. What have I done exactly? Have I created a key called name with the value of an array?
Of course I know I can do that by just doing
topics.name = ["chapter 1", "chapter 2", "chapter 3"];
But then what is this doing?
topics[name] = ["chapter 1", "chapter 2", "chapter 3"];
Could someone please clarify?
topics[name] = ["chapter 1", "chapter 2", "chapter 3"];
andtopics["name"] = ["chapter 1", "chapter 2", "chapter 3"];
? – Matt Fellows Oct 21 '11 at 13:26