Why is comparing the ".constructor" property of two windows unreliable? <p>I'm trying to understand why the following is not working as I would think it does. I'd like to check whether an object is a window. I was thinking that checking the constructors of the current window and another window would work.</p> <p>So, first creating another window:</p> <pre><code>var popup = window.open('', '', ''); </code></pre> <p>And then checking with:</p> <pre><code>popup.constructor === window.constructor; </code></pre> <p>But for some reason the results vary among browsers:</p> <ul> <li>IE7: Returns <code>true</code> <ul> <li>But that's simply because <code>.constructor === undefined</code></li> </ul></li> <li>IE8: Returns <code>false</code></li> <li>IE9: Throws an error with no text (<code>""</code>)</li> <li>Chrome: Returns <code>false</code> <ul> <li>Though in both cases <code>.constructor === DOMWindow</code> - but <code>DOMWindow</code> is not accessible directly like this</li> </ul></li> <li>Opera: Returns <code>false</code> <ul> <li>Though in both cases <code>.constructor === Object</code></li> </ul></li> <li>Firefox: Returns <code>false</code> <ul> <li>Though in both cases <code>.constructor === Window</code></li> </ul></li> </ul> <p>Why isn't this reliable and working correctly? jQuery simply checks for <code>"setInterval" in window</code>, but I'd like to create a more robust function for checking whether an object is a window.</p>