Results 1 to 5 of 5
Thread: how to avoid global variables?
Jul 29, 2011, 05:43 #1
- Join Date
- Apr 2011
- Mexico city, Mexico
- 1 Post(s)
- 0 Thread(s)
how to avoid global variables?
I have a form which the user is able to change the id of, so I have declared an array containing the details of the form and the array is updated in case the details of the form change, so I can have something like
formdetails = ['someid', 'index.html', 'post'];
but the user can change any of those and the form details could be updated to:
formdetails = ['someotherid', 'form.php', 'get'];
then from inside the function I can call the form by doing:
I am still learning JS and have read a lot that is best to avoid, as much as possible, the usage of global variables and would like to know how I could use that same updated array or any other variable inside a function if is not globalDo you get bothered because I do the same thing every day?
Do you question why I do it?
Then find something that you actually like doing!!!
Stop thinking on what I do.