mmmh... overwriting the constructor property doesn't sound like a great idea to me. What about all the code that has been written by developers expecting the constructor to be what it is supposed to be: Object
You could use other particular properties of any jQuery object: they are not arrays but they have a length property: !$.isArray($obj) && ($obj.length !== undefined) It is not perfect but it can help. On Sep 17, 8:04 pm, Nico <nicolas.deve...@gmail.com> wrote: > Hi, > > I first posted this message on the jquery-en group, but it should > probably be posted here, so here am I. > > In some cases, I have to check if a variable is a jQuery object or > not. Usually, to check a variable type, I use the "constructor" > property > (when I can't use typeof, which is not accurate). > In case of jQuery, the constructor property equals Object, so I can't > use it. > When I create a jQuery Object, it's known by javascript as an object, > and it behaves like a function. > > Would it be possible to add something so we could get a true with this > example : > > $([]).constructor === jQuery > > This would be great, no ?? The only change to do is to add in the > beginning of jQuery.fn.init method the line : > > this.constructor = jQuery; > > This way, all jQuery's objects "constructor" property equals jQuery. I > quickly tried this, and I met no bugs. > > Any arguments against this ? > > Nico --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---