There are two main problems in global variable.
- limited space
- Global variables are one of the main reasons for memory leaks.
- Variable collision
<script>var x = 1</script> <script>var x = 2000</script>
In HTML file all these tags get combined essentially into one
execution context which means everything is our the global execution context and
overwrite each other. This creates a lot of bugs.
How to solve this? Module