jQuery's .isWindow method?
<p>I was trying to understand what I could from jQuery's animation functions, but ended up running into all sorts of internal functions I didn't understand, and ultimately landed on isWindow. The code for isWindow checks to see if an object has the property <code>setInterval</code>, and returns false otherwise.</p>

<p>Of course, any object could have the property <code>setInterval</code> without being the window, and although it would almost have to be a deliberate attempt to sabotage jQuery's functionality to have an object with that exact property name, I can imagine some reasonable cases where it could be unintentional. </p>

<p>Is there not a better way to check if an object is a window object? Couldn't they use something along the lines of</p>

<pre><code>obj.setInterval &amp;&amp; obj.setInterval.toString() == 'function setIternval(){ [native code] }
</code></pre>

<p>I know the return of <code>toString</code> of an internal function isn't going to be standard across all browsers, but the writers of jQuery seem to have a great understanding of these cross-browser differences. I'm also aware that this isn't a fool-proof method either, as someone could easily override the <code>toString</code> method to return that same string, but this would still prevent the problem of having an object mistaken for a window. </p>

<p>I wouldn't ask if I thought that <code>isWindow</code> was only used on internal objects by jQuery, but it was part of <code>isPlainObject</code>, which is used in <code>.extend</code>, which can be used on external objects. </p>
