Scope

A variable is not always available everywhere in your program. Some variables can be used anywhere, while others can only be used inside a function or a block.This is called Scope.

Types of Scope in JavaScript

Global Scope - A variable declared outside any function or block is called a Global Variable.It can be accessed from anywhere in the program.

Eg: