Software-Engineering
# What are Scopes in JS?
When we declare variables in JS, we declare a variable at a different scope.
Variables can be declared
- globally
- locally
- window scope
# Types of Scopes
global scope
can be accessed everywhere in same file.
local scope
can only be accessed in certain block code.
window scope
no explicit variable-type. accessible everywhere in the code
# Block Scoped
use let
, const
# Scoped to function
use var
BUT: TRY TO AVOID var