I can't understand why window
is under self
and self
is under window
object.
if you go to dev-tools or Firebug and write window
you got DOM window
object that self
is under this object. The weird part is that window
is under self
again!
You can write
window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self.window.self
and still you get window
object!
How?!
In a response to one of my comments:
It is a circular reference, so it doesn't end. The compiler only creates one reference. It just happens to be a reference back to the original object on which the reference was created. That's why you can do window.window.window... Like this: var obj = {}; obj.obj = obj;. There's only one reference created but it's a reference back to the original, so you can do obj.obj.obj.obj.obj.obj.obj === obj.
Comment can be seen here: Is window really global in Javascript?
See this page, and see here. window.window
is a reference to itself, so you can repeat window.window.window ... window
, it will allways return the current window. self
returns a reference to the current window, so here it's the same, it will allway return the DOMWindow
Object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With