|
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.
|