How can you avoid using so-called globals in situations like this ...
For instance, I have an array of values that I need for some widget on the page. The user can click a button and retrieve new values from the server (using "AJAX") and these are inserted into the array and the widget is updated.
Whether it's the widget or a "global" that holds the array, one of these will need to be "global."
Finally, I'm using "global" in quotes because it's not really global. As this page says, your new variable becomes part of the window object.
↧