Organizational Research By

Surprising Reserch Topic

check if object is a jquery object


check if object is a jquery object  using -'javascript,jquery'

Is there a fast way of checking if an object is a jQuery object or a native JavaScript object?

example:

var o = {};
var e = $('#element');

function doStuff(o) {
    if (o.selector) {
        console.log('object is jQuery');
    }
}

doStuff(o);
doStuff(e);


obviously, the code above works but it's not safe. You could potentially add a selector key to the o object and get the same result. Is there a better way of making sure that the object actually is a jQuery object?

Something in line with (typeof obj == 'jquery')
    
asked Sep 16, 2015 by 20shahi
0 votes
5 views



Related Hot Questions



Government Jobs Opening


...