I am wondering what is the safest way to test if a variable is a jQuery object. I am building a function where I want to be able to pass in either the id of the form or the form object itself. The current way I am doing this is
var $form = (form instanceof jQuery ? form : $('#' + form)); Is this the safest way that is not likely to change? Would I be better offer wrapping this functionality into a function all by itself so incase this does change, I only need it to change in one spot (plan on building a complete UI type framework)?