问题
What is Window ?
Here's what I see on the console in Chrome :
window
Window {top: Window, window: Window, location: Location, external: Object,
chrome: Object…}
Window
function Window() { [native code] }
回答1:
Window is a function, as you can see. It's the constructor for the windows (but you can't build new windows directly with the constructor, you usually use the Window.open function). Window.prototype thus holds the methods you can call on the window).
window is the global variable holding an instance of Window, it represents the browser window containing your document (not really a "window" usually, rather a tab in modern browsers).
You can check that
window instanceof Window
is
true
回答2:
Window is the constructor function that is used to create window.
To see this, try alert(window.constructor === Window).
来源:https://stackoverflow.com/questions/23547708/javascript-window-vs-window