Alex Rivera | Logout

Why is window not identical to window.self in Internet Explorer?

Asked 2010-04-27T21:13:05.303
26

There's a convoluted backstory involving how I came across this, but why is the self property not exactly equal to the window itself?

In Safari and Firefox and friends, the results are as I'd expect:

> window == window.self
  true
> window === window.self
  true

The same isn't true in Internet Explorer, though:

>> window == window.self
   true
>> window === window.self
   false

Can anybody account for the inconsistency? To exactly what is the self property of the window object pointing? It casts to something with equality, which is even more vexing.

Edit
Report

1 Answer

4

Nice question. It does it with document and document.parentWindow too:

window == document; // true
window === document; // false

window == document.parentWindow; // true
window === document.parentWindow; // false

The big wtf for me though is:

window == document; // true
document == window; // false

You can swap out window with this in any of the above examples (and stay in the global context) with the same results. It makes the == operator even more suspect.

Why it behaves this way is so beyond me.

answered 2010-04-27T22:08:30.480

Your Answer