What is Scope?
Scope in JavaScript refers to the accessibility of variables, functions, and objects during runtime.
In JavaScript, there are three types of scopes:
- Global Scope
- Functional Scope
- Block Scope
Global Scope:
Global scope is the outermost scope, a variable is in global scope if it’s declared outside of a block.
window
and document
are global variables provided by the browser.