Issues with global variable

There are two main problems in global variable.

  1. limited space
    • Global variables are one of the main reasons for memory leaks.
  2. Variable collision

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

Leave a Reply

Your email address will not be published.

ANOTE.DEV