osdir.com
mailing list archive

Subject: Re: Prototype is spamming my arrays! - msg#00004

List: lang.ruby.rails.spinoffs

Date: Prev Next Index Thread: Prev Next Index
x = [1,2,3];
x.each(function (i) {
document.write(i);
});

On 11/4/05, Martin Scheffler <wooyay-S0/GAf8tV78@xxxxxxxxxxxxxxxx> wrote:
>
> Hi all, when I want to interate through an array, all those pesky Prototype
> functions get in my way!
>
> When I do this:
> ---------------------
>
> r="";
> for(x in new Array()) {
> r+="var: "+x+", val: "+ (new Array())[x]+"\n";
> }
> alert(r);
>
>
> ---------------------
> I get a giant alert window with loads of functions printed out.
> Is this a bug, or is there a better way to iterate over arrays?
> __________________________________________________________________________
> Erweitern Sie FreeMail zu einem noch leistungsstarkeren E-Mail-Postfach!
> Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131
>
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@xxxxxxxxxxxxxxxx
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Prototype is spamming my arrays!

Hi all, when I want to interate through an array, all those pesky Prototype functions get in my way! When I do this: --------------------- r=""; for(x in new Array()) { r+="var: "+x+", val: "+ (new Array())[x]+"\n"; } alert(r); --------------------- I get a giant alert window with loads of functions printed out. Is this a bug, or is there a better way to iterate over arrays? __________________________________________________________________________ Erweitern Sie FreeMail zu einem noch leistungsstarkeren E-Mail-Postfach! Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131

Next Message by Date: click to view message preview

Re: Prototype is spamming my arrays!

The for ... in ... loop in JavaScript iterates through an objects properties, which aren't necessarily only array items. Use the way Jon has proposed. Thomas Am 03.11.2005 um 21:55 schrieb Martin Scheffler: Hi all, when I want to interate through an array, all those pesky Prototype functions get in my way! When I do this: --------------------- r=""; for(x in new Array()) { r+="var: "+x+", val: "+ (new Array())[x]+"\n"; } alert(r); --------------------- I get a giant alert window with loads of functions printed out. Is this a bug, or is there a better way to iterate over arrays? ______________________________________________________________________ ____ Erweitern Sie FreeMail zu einem noch leistungsstarkeren E-Mail- Postfach! Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131 _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@xxxxxxxxxxxxxxxx http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Previous Message by Thread: click to view message preview

Prototype is spamming my arrays!

Hi all, when I want to interate through an array, all those pesky Prototype functions get in my way! When I do this: --------------------- r=""; for(x in new Array()) { r+="var: "+x+", val: "+ (new Array())[x]+"\n"; } alert(r); --------------------- I get a giant alert window with loads of functions printed out. Is this a bug, or is there a better way to iterate over arrays? __________________________________________________________________________ Erweitern Sie FreeMail zu einem noch leistungsstarkeren E-Mail-Postfach! Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131

Next Message by Thread: click to view message preview

Re: Prototype is spamming my arrays!

The for ... in ... loop in JavaScript iterates through an objects properties, which aren't necessarily only array items. Use the way Jon has proposed. Thomas Am 03.11.2005 um 21:55 schrieb Martin Scheffler: Hi all, when I want to interate through an array, all those pesky Prototype functions get in my way! When I do this: --------------------- r=""; for(x in new Array()) { r+="var: "+x+", val: "+ (new Array())[x]+"\n"; } alert(r); --------------------- I get a giant alert window with loads of functions printed out. Is this a bug, or is there a better way to iterate over arrays? ______________________________________________________________________ ____ Erweitern Sie FreeMail zu einem noch leistungsstarkeren E-Mail- Postfach! Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131 _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@xxxxxxxxxxxxxxxx http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by