[Proto-Scripty] Re: Problem with prototype and arrays.

2010-08-02 Thread T.J. Crowder
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,

[Proto-Scripty] Re: Problem with prototype and arrays.

2010-08-02 Thread RobG
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

[Proto-Scripty] Re: Problem with prototype and arrays.

2010-08-02 Thread T.J. Crowder
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,

[Proto-Scripty] Re: Problem with prototype and arrays.

2010-08-02 Thread RobG
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

[Proto-Scripty] Re: Problem with prototype and arrays.

2010-08-01 Thread T.J. Crowder
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

[Proto-Scripty] Re: Problem with prototype and arrays.

2010-08-01 Thread Rog
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 >

[Proto-Scripty] Re: Problem with prototype and arrays.

2010-08-01 Thread T.J. Crowder
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,