Is there a way to make a jQuery object evaluate to false when it's created if its length is 0?
Here's what I'd like to be able to do:
var Constructor = function (config) {
this.obj = $(config.id) || null;
};
But that doesn't work -- if config.id is not passed or #id is not found, this.obj becomes an empty jQuery object that evaluates to true.
What I want is for this.obj to be null on creation (or to be a populated jQuery object if the arg/id exists) and to avoid having to check the length of the resulting jQuery object.
lengthproperty of the object