View Single Post
Old 12-14-2012, 01:23 AM   PM User | #8
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,452
Thanks: 0
Thanked 498 Times in 490 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Why not just wrap your entire code inside an anonymous self executing function. That way any variables you declare will be limited to that function and will not be global - but they will be available to any functions defined inside the anonymous one.

Don't get rid of the var - once you start writing strict javaScript all variables MUST be declared or the script will crash with a reference error.

I'd also pass req into the function as a parameter since the function needs it.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote