Scopes In Javascript

Gabriela Johnson
1 min readJan 10, 2021

Hello. My name is Gabriela and I am currently a student in Flatiron School, and we just finished up our Javascript module. In this article, id like to go over an important concept in Javascript called scoping. To start, heres the definition.

Scope : refers to the current context of code, which determines the accessibility of variables to JavaScript.

In other words, if a variable or other expression isn't in the current scope, you wont be able to use it. To start, we have whats called a global scope, thats available globally. Its good practice to create variables with let,const, or var, but once those words are removed, the variable becomes globally scoped, and can be accessed throughout our program.

On the other hand, we have whats called a Block Scope, which is created when we use let,const, but NOT var.

Lastly, we have whats called a Function Scope. When we declare a function, that function has created its own scope, which is NOT global. With that being said, variables, etc that are defined inside of that function are to be called inside of that function only, being that they are in that functions scope.

--

--