Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
https://teamtreehouse.com/library/thinking-globally <-- here mr guil says that all global variables belong to a global object called window in browsers but mdn says "the Window interface represents a window containing a DOM document; the document property points to the DOM document loaded in that window. A window for a given document can be obtained using the document.defaultView property.
how do all global variables belong in the global object window when window is a global variable?
Wiktor Bednarz18,647 Points
So to picture it out for you - let's assume we've got some website living on a domain 'http:\www.mygloriouswebsite.com' and on that website you've got your homepage, contact page, and some about page. Whenever you visit each one of those pages, the browser creates a new window object. Within this object, it executes all the scripts attached to it. And even though you may have one script file attached to every site on your website, the browser executes it from scratch on each visit to the site.
ti;dr - Even though window object could be considered a variable itself, for a browser it defines the scope of execution for the code attached to it.
I hope this answers your question,
thank you for explaining