Scopes

What are scopes? to it seems normal code to me.

Scopes are like boundaries or groups. There are three main scopes in JavaScript: block scope, function scope and global scope. Variables/functions create in global scope can be accessed anywhere in the code. Variables/functions created in a function are function-scoped, which means they can only be accessed from within the function. Anything that is block scoped can only be accessed from within the block it was created in. (A block is anything enclosed in {}-loops, if…else statements, etc). Here is some reading on the matter.

1 Like