The term "scope of variables" describes how widely a given variable may be used in the code.  Let us say that you perform two distinct roles. In function 1, you define a variable. Then you go to the subsequent function, which is function 2. Now, you can use the variable created in Function 1 in Function 2. A JavaScript variable's scope is the area of code in which it can be used.  The scopes of JavaScript variables are as follows:  Global Scope: A variable with global scope is one that has been defined outside of a function.  Example:  var globalVariable = "This is a Global variable";
// Code present here can use globalVariable
function myFunction() {
// Code present here can also use globalVariable
}  Local Scope: A variable with the local scope is one that has been declared inside a function.  Example:  // Code present here cannot use localVariable
function myFunction() {
var localVariable = "This is a local variable";
// Code present here can use localVariable
}  Block Scope: The "block scope" variables defined inside a certain block (denoted by {}) are inaccessible from outside of that block.  Function Scope: When you write a function in JavaScript, you are really establishing a new scope.