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