> It isn't intuitive that jQuery always returns an array-like object.

If jQuery didn't return a jQuery object, you would not be able to
chain methods. Chaining is at the core of jQuery's design. In many
cases you don't even need to "check if an id exists", since any
following methods in the chain will operate on an empty jQuery object
and do nothing:

$("#someID").hide();

If #someID exists, it will be hidden. If it doesn't exist, nothing
will happen because the .hide() method will be applied to 0 DOM
elements. Imagine if the $() method returned a null in those cases.
Instead of chaining you'd have to do something like this:

var myid = $("#someID");
if ( myid )
  myid.hide();

Very, very, not like jQuery.


> One assumes that a failed search returns nothing.

It does return nothing. That's what a zero in the .length property
or .size() method is telling you: "There are no selected DOM elements
in this jQuery object."

Reply via email to