I am studying a book on Javascript, "Javascript: The Definitive Guide - David Flanagan". Chapter 3 of this book talks about the Global object, here, they say that
global Window object has a self-referential window property that can be used instead of this to refer to the global object.
What I understand from the above line is that window is not the object instead it is self-reference, but could someone explain me in detail how it is.. and how to create a self-referential property for a custom object.
Like in chrome console if I type in window i get
Window {top: Window, location: Location, document: document, window: Window, external: Object…}
How to achieve the same for custom objects. Sorry, if I understood this totally wrong please excuse me for that, I am newbie to JS.
Self-referential means that the Window object has a property which references itself.
window.window = window
When you're in the window scope, this === window so you can reference properties like window.location using the following methods.
window.locationthis.locationlocationwindow.window.locationthis.window.locationIf 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