JavaScript Function Scope
Jun 10, 2021
I like to think of scope as visibility. Where are you able to see 👀 this variable that you have declared. Well, it depends on where you have placed it.
Function Scope local vs global
If the variable is outside of a function it is a global scope. Everyone can see it. If the variable is inside the function is a local scope. Only you can see it.
Local Scope
The variable (fluffColor) is inside of the function. When you run console.log(fluffColor) you will get undefined.
Global Scope
The variable (fluffColor) is outside of the function. When you run console.log(fluffColor) you will get blue.
Reference