What’s the difference between Window and Window

Asked

Viewed 131 times

3

A few months ago I’ve been studying Javascript and now that I realize that you have two "equal" objects: the Window and the window.

Why are there two and what’s the difference between them?

Editing: I actually saw that Window is a Function and not object.

1 answer

4


Window is the constructor, so it is seen as a function, if you type

window instanceof Window

Will return true, already window is the global variable that is the same as this of the global scope test in the browser console

window === this

You will see that it will return true too, being more specific window is the instance of Window, it is worth mentioning that you cannot do new Window() and yes Window.open, so if you have a declared global variable with a var and in the global scope, if you go to the console and type window.nameVariable will be possible to access it, the same with this.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.