Scope: It is a region of the program where a variable can be accessed. In other words, scope determines the accessibility/visibility of a variable.
JavaScript has 3 types of scope: Global Scope, Function Scope and Block Scope
Global Scope: Variables declared Globally (outside any function) have Global Scope. Global variables can be accessed from anywhere in a JavaScript program.
Local Scope: variables declared inside the functions are considered to be of the local scope and it is further divided into function scoped and block scoped.
Function scope is within the function. Block scope is within curly brackets.
Function Scope: When a variable is declared inside a function, it is only accessible within that function and cannot be used outside that function.
Block Scope: A variable when declared inside the if/else conditions or inside for or while loops, are accessible within that particular condition or loop.