Most accurate isWindow function
What about taking advantage of the (stupid) fact that the context parameter inside a function invoked without call or apply will be the window?

mYApp.isWindow = function(obj) {
  if(!obj)
    return false
  return obj === (function() { return this})() //is this the window
     || obj.eval &amp;&amp; obj.eval.call &amp;&amp; obj.eval("this === (function(){ return this })()") //is that another window
     || false; //make undefined false
};


Seems to even work when wrapped in a with. That being said, you might have legitimate reasons to want to test for this but I can't think of any.

Edit: Added check for 'other' window. You could probably add some finagling to check that eval isn't a stub that always returns true. So if it returns true for example you could generate two random numbers, add them together, and then pass them into the eval string and have it add those numbers and confirm the result is indeed accurate. Let's be honest though, that's stupid, if someone wants to trick you that bad, they'll find a way.