I don't know in which case an each over a definition (prototype with a
length) could be useful ... I think a forEach as for in could be explicit
and less ambiguous for these weird case (I mean, you have the same problem
with window object, don't you?)

A=0;$.each(window,function(){ A++; });A

... A is 0

what about this?


    forEach:function( object, callback, args ){
        if ( args )
            for ( var name in object )
                if ( callback.apply( object[ name ], args ) === false )
                    break;
        else
            for ( var name in object )
                if ( callback.call( object[ name ], name, object[ name ] )
=== false )
                    break;
    },

    // args is for internal usage only
    each: function( object, callback, args ) {
        var i = 0, length = object.length;
        if(length === undefined)
            jQuery.fn.forEach( object, callback, args );
        else if(args)
            for ( ; i < length; )
                    if ( callback.apply( object[ i++ ], args ) === false )
                        break;
        else
            for ( var value = object[0];
                    i < length && callback.call( value, i, value ) !==
false; value = object[++i] );
        return object;
    },


On Thu, Mar 5, 2009 at 3:34 PM, Ariel Flesler <[email protected]> wrote:

>
> I dunno how is Firebug sniffing arrays, maybe like:
>
> if( this._proto_.length !== undefined )...
>
> In that case, this change would matter, anyway....
>
>
> As for the other thing, I suppose it happened  because I was using
> $.each to iterate $.fn.
> Go to jquery.com, then try this on Firebug's console:
>
> A=0;$.each($.fn,function(){ A++; });A
>
> You'll get 132.
>
> Now execute $.fn.length = 0; and try again.
>
> On Thu, Mar 5, 2009 at 1:13 PM, Andrea Giammarchi
> <[email protected]> wrote:
> > if length is always assigned, you do not need it in the prototype, so why
> > you asked if that was the problem? :-)
> >
> > I did not get the proto un-iterable but generally I prefer properties as
> > methods in the prototype rather than assigned runtime, so you can spot
> > everything simply logging the constructort.prototype or reading it, no?
> > Prototype as definition, in few words
> >
> >
> >
> > On Thu, Mar 5, 2009 at 2:45 PM, Ariel Flesler <[email protected]>
> wrote:
> >>
> >> Each instance gets a length within $.fn.init, no exception. So that
> >> prop was redundant.
> >> It might also made the proto un-iterable back then when I needed to do
> >> that.
> >>
> >> So, why re-add it ?
> >>
> >> On Thu, Mar 5, 2009 at 12:12 PM, Andrea Giammarchi
> >> <[email protected]> wrote:
> >> > Since every call to jQuery returns an ArrayLike instance I think you
> >> > should
> >> > put back the length:0 into the prototype (could be also useful to
> >> > understand
> >> > different instances via constructors prototype).
> >> >
> >> >
> >> > On Thu, Mar 5, 2009 at 1:30 PM, Ariel Flesler <[email protected]>
> >> > wrote:
> >> >>
> >> >> Maybe because we removed:
> >> >>
> >> >>  length:0,
> >> >>
> >> >> from jQuery's prototype ?
> >> >>
> >> >> --
> >> >> Ariel Flesler
> >> >> http://flesler.blogspot.com
> >> >>
> >> >> On Mar 5, 12:40 am, John Resig <[email protected]> wrote:
> >> >> > It's supposed to be - and this was a change in Firebug, not in
> jQuery
> >> >> > - it was actually a regression in Firebug that this no longer
> worked.
> >> >> >
> >> >> > --John
> >> >> >
> >> >> > On Wed, Mar 4, 2009 at 7:25 PM, Ricardo Tomasi
> >> >> > <[email protected]>
> >> >> > wrote:
> >> >> >
> >> >> > > Why is it that Firebug reports jQuery objects as simple arrays in
> >> >> > > 1.3.2? 1.2.6 always returned me the actual jQuery object. Is this
> a
> >> >> > > bug (i'm on Firefox 3.0.7) or is it supposed to be this way? How
> >> >> > > can I
> >> >> > > inspect the actual object?
> >> >> >
> >> >> > > - ricardo
> >> >> >
> >> >> >
> >> >>
> >> >
> >> >
> >> > >
> >> >
> >>
> >>
> >>
> >> --
> >> Ariel Flesler
> >> http://flesler.blogspot.com
> >>
> >>
> >
> >
> > >
> >
>
>
>
> --
> Ariel Flesler
> http://flesler.blogspot.com
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to