Are you wondering what is the window object and why we have still not talked about it in detail? Well, the window object is actually a global object that represents the browser’s window.
You can simply log “this” in your console window to get the window object. Why don’t you give it a try?
console.log(this);
You would see something like this on your screen
All the global variables and methods are bond with this global window object. You have already seen some of these methods such as console.log() and alert().
What you need to know about window object is that it is a global object which is accessible by all browsers and it refers to the instance, which is currently open in the browser. Since it is global to the browser, you can optionally choose to omit it when accessing its properties or method for the sake of writing less code.
This is the reason that you can write console.log() and it still works because the console is a function defined in the window object. Everything you write in a JavaScript code is enclosed inside this window object. Window object has direct control over the browser, as it represents the browser.