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,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Jul 31, 1:44 pm, Rog <ro...@aidreams.co.uk> wrote:
> Hi there everyone, I am pretty new to javascript but do a lot of other
> programming.
>
> Something is not working as expected.  Here's a bit of code I am
> testing :
>
> ==================================
> <html>
> <head>
> <script type="text/javascript" src="prototype1-1-6.js"></script>
> </head>
> <script>
>
> var smileySet = new Array();
>
> smileySet['test'] = 'hello';
> for (var smiley in smileySet)
>         document.write(smiley + ' = ' + smileySet[smiley] + '<br />');
>
> </script>
> </html>
> ===================================
>
> If I run that I get a screen full of the prototype javascript
> functions.  Without including prototype I just get the one array
> element 'test = hello' as expected.
>
> Why are all the prototype functions being added to the array ?
>
> Many thanks !

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to