JavaScript Global Variables

JavaScript Global Variables


JavaScript Global Variables
A global variable has global scope which means it is defined everywhere in your JavaScript code.JavaScript global variable is declared outside the function or declared with window object. It can be accessed from any function.
  • Global environment for functions, var etc.
Example: Let’s see the simple example of global variable in JavaScript.
Output
After clicking the “summit” button
5
11
18
26
35