Thank you kangax,

What you`ve said about an object, what do you mean ? I`m currently a
newbie in JavaScript (or atleast i`m not so into object oriented
programming) and some things are really new for me. Thank you very
much for your assistance.

On Sep 21, 6:58 am, kangax <[EMAIL PROTECTED]> wrote:
> On Sep 20, 6:40 pm, Spalx <[EMAIL PROTECTED]> wrote:
>
> > Hi guys,
> > I`ve recently started using prototype because of its Ajax functions,
> > though it doesnt let me use the for(in) function of JavaScript, so
> > i`ve referred to the array.each function, though that doesnt quite
> > work how i need it to. Here`s what i have:
> > var arr = new Array();
> > arr[2] = "some text";
> > arr[5] = "some text";
> > arr[24] = "some text";
>
> > ... now when i use array.each ... it doesnt give me the indexes i`ve
> > set, but the ones starting from 0 (0,1,2) ... which is a problem for
> > me, with for(x in arr) it was working perfectly because i would get
> > "x" and everything was perfect, but now it doesnt seem to work ... how
> > can i solve that ? Any tips ? Thanks in advance.
>
> You can still get the same functionality using `for..in` (but skipping
> properties from the prototype chain):
>
> var arr = [];
> arr[2] = "some text";
> arr[5] = "some text";
> arr[24] = "some text";
>
> for (var i in arr) {
>   if (arr.hasOwnProperty(i)) {
>     // ...
>   }
>
> }
>
> A better way might actually be to enumerate with `for (;;)` or just
> use an object (rather than an array). Both ways make "keys" easily
> accessible.
>
> --
> kangax

--~--~---------~--~----~------------~-------~--~----~
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-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to