So what is a Scope?
The Global scope is the main window or window object, any variable or function that is declared within the global scope is accessible anyplace in your code. For example, think of the global scope as a fish tank, within the fish tank there is a castle (function) and two fish (variables). You as a human can access anything within the fish tank and manipulate it however you please.
Below is code snippet that ties my fish tank example and code together.
Keep in mind you cannot see the window object (fish tank) but it’s there.
Now there is one more Scope that is a little more involved when it comes to it’s understanding and that is the infamous Closure Scope. I will be covering this concept more in depth in another post, just to make sure I get to all the ins and outs of the subject.
If you have any questions about this specific example please feel free to contact me or leave a comment.