Looks like we're sending the same conclusions at the same time!  Great
minds think alike.

This is part of a class and I don't know that it's called 'foo'.  I
just know I want the first one.



On May 25, 10:51 pm, rpflo <rpflore...@gmail.com> wrote:
> Thanks for the reply ... This works though:
>
> console.log(object['foo']);
> console.log(object['bar']);
>
> And that works identically to an array:
>
> object=['foo','bar','baz'];
> console.log(object['foo']);
> console.log(object['bar']);
>
> Is there no way to just find the first one in an object?
>
> On May 26, 12:40 am, Eneko Alonso <eneko.alo...@gmail.com> wrote:
>
>
>
> > Objects are not arrays, so you cannot index them.
> > You can try an for loop, which will probably give you the elements on the
> > same order always, but this is not guaranteed and may change from browser to
> > browser or if the object gets modified.
>
> > var object={
> >        foo:'a',
> >        bar:'b',
> >        baz:'c'}
>
> > for (key in object) {
> >     console.log(key, object[key])
>
> > }
>
> > This doesn't have anything to do with Mootools by the way.
>
> > On Mon, May 25, 2009 at 9:34 PM, rpflo <rpflore...@gmail.com> wrote:
>
> > > So if I've got:
>
> > > var object={
> > >        foo:{},
> > >        bar: {},
> > >        baz: {}
> > > }
>
> > > How would I ...
>
> > > var first = object[0];
> > > console.log(first);
>
> > > Obviously that doesn't work because the first index is named "foo",
> > > not 0.
>
> > > I've messed around with $pick and $arguments, but can't figure it out.
>
> > > There's probably a very simple non-moo way to do this, but I'm hardly
> > > versed in "real" javascript--to my own detriment for sure.
>
> > > Thanks!

Reply via email to