Since jQuery Deferreds are created by copying methods of a hidden object instead of calling a new operator in a function, you cannot prove that the object is really an instance of jQuery.Deferred. I think you need to go with Duck-Typing:
"When I see a bird that walks like a duck and swims like a duck and quack, like a duck, I call this bird a duck." - James Whitcomb Riley
Depending on which objects might otherwise be returned (which properties should be expected), check to see if there are any properties / methods:
var x = getMysteriousObject(); if (x.promise) {
You can view this check in detail:
if ($.isFunction(x.promise)) {
or (to distinguish pending objects and other implementations of the Promise interface)
if (x.promise && x.resolve) {
Niko Jun 09 2018-12-12T00: 00Z
source share