I'm hesitant to add that (I've definitely thought about it, in the past)
because .valueOf() doesn't cover all comparison cases.

obj > obj2 works (as you noted)
but if ( obj ) {} doesn't (it always returns true)

Additionally, in Firebug, the result shows up as a number rather than
something more useful (like a list of elements).

--John


On Thu, Jul 23, 2009 at 2:06 PM, James Padolsey <
jamespadol...@googlemail.com> wrote:

>
> Just a thought; this would be quite useful IMO:
>
> var paras = $('p'), uls = $('ul');
> if (paras > uls) {
>    // ...
> }
>
> I know it's not quite as readable (or as semantic) as:
>
> if (paras.length > uls.length) {
>    // ...
> }
>
> but still, it's one of those things that may as well be added, just
> for the few situations where it may be useful.
>
> jQuery.fn.valueOf = function(){return this.length;};
>
> Unless it's got some other valid use (with jQuery)...?
> >
>

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

Reply via email to