var $test = $(window).add(document).add("body");
$test.is(function(index, elements) {
return this === window;
});
jQuery's "is ()" method checks the nodeType type of the elements to pass. The document has a nodeType of 9. The body is of type nodeType 1. The window does not have nodeType, ergo "undefined", which evaluates to false. To get around this, create your own filter function, as shown above.
source
share