Hi,
> I'm missing something here.
One of us is. :-)
The OP's problem was that using for..in on an array was looping
through the property names and he expected it to loop through array
indexes. That's the common misconception I was talking about. People
think for..in loops through array indexes,
On Aug 3, 2:19 am, "T.J. Crowder" wrote:
> Hi,
>
> > > Yes, it's an extremely common misconception.
>
> > What, that for..in iterates over an object's properties?
>
> No, that it loops over array indexes.
I'm missing something here. Array indexes are properties, which is why
they are included i
Hi,
> > Yes, it's an extremely common misconception.
>
> What, that for..in iterates over an object's properties?
No, that it loops over array indexes.
-- T.J.
On Aug 2, 3:49 pm, RobG wrote:
> On Aug 2, 3:43 pm, "T.J. Crowder" wrote:
>
> > Hi,
>
> > > I found that array looping method online,
On Aug 2, 3:43 pm, "T.J. Crowder" wrote:
> Hi,
>
> > I found that array looping method online, I guess I will remove that
> > page from my bookmarks.
>
> Yes, it's an extremely common misconception.
What, that for..in iterates over an object's properties? It's per
ECMA-262. There are strategies
Hi,
> I found that array looping method online, I guess I will remove that
> page from my bookmarks.
Yes, it's an extremely common misconception.
> Thanks for setting me right :)
No worries!
-- T.J. :-)
On Aug 1, 5:23 pm, Rog wrote:
> Thanks very much, that makes a lot of sense now.
>
> I fo
Thanks very much, that makes a lot of sense now.
I found that array looping method online, I guess I will remove that
page from my bookmarks.
Thanks for setting me right :)
On 1 Aug, 11:47, "T.J. Crowder" wrote:
> Hi,
>
> `for..in` is not for looping through the indexes of an array, it's for
>
Hi,
`for..in` is not for looping through the indexes of an array, it's for
looping through the property names of an object. More in the API docs:
http://api.prototypejs.org/language/array/
...and in the unofficial wiki:
http://proto-scripty.wikidot.com/prototype:tip-looping-through-arrays
HTH,