In the discussion herehere, the comments in the accepted answer suggest that I approach the given code from a functional perspective, which was new to me at the time. Wikipedia said, among other things, that FP "avoids state and mutable data", which includes according to the discussion global vars. Now, being that I am already pretty far along in my project I am not going to learn FP before I finish, but:
How is it possible to avoid global vars if, for instance, I have a UI whose entire functionality changes if a mousebutton is down? I have a number of things like this.
Why was there a strong negative reaction among some experienced coders to implementing FP in JS? When I brought up what seemed to me to be supportive comments by Crockford, people got even madder. Are there strong arguments against using fp in JS? What constitutes a "functional language" and why is JS "not it"?