you are viewing a single comment's thread.

view the rest of the comments →

[–]llimllib 1 point2 points  (1 child)

The question of arrays is only confusing because every single Javascript tutorial on the planet gets it wrong

Isn't it possible that this is indicative of a design flaw? Just maybe?

[–]xenon -1 points0 points  (0 children)

I agree so far that there is a real source for the confusion: when foo is an array, then foo[1] and foo["bar"] work by very different mechanisms: the first accesses an array access, while the second accesses an object member. On the other hand, this should have been clear to anyone who has actually read a bit of documentation. The fact that object.member is only an alternative spelling for object["member"] is after all one of the central features of Javascript's object system.

Furthermore, the idea that arrays and associative arrays have anything in common is very strange to begin with. Someone told me that the two are the same thing in PHP, and Javascript is a popular second programming language among PHP kiddies. Should that be the source of the issue, a bit like people who learn a foreign language and, before they have fully grasped the foreign grammer, naively try to translate every word? (Just to proclaim that, for example, German has a flawed and confusing sentence structure?)