[thelist] [JavaScript] way around these global vars?

Tom Dell'Aringa pixelmech at yahoo.com
Tue Feb 7 10:14:36 CST 2006


Yeah, that would work wouldn't it. Am I going too far down the oo road here? Should I not worry
about the global vars and just go ahead with it? Is there any performance difference in the object
method vs. plain vars method? I mean the function works fine, I'm just anal about writing the best
code I can, and the easiest to maintain.

Thanks

Tom

--- Christian Heilmann <codepo8 at gmail.com> wrote:

> Encapsulate your function in one object and set the variables as
> object properties?
> 
> stickystate{
> lastImg:null,
> currentBtn:null,
> showHit:function(o){
> ...
> }
> }
> 
> You can then call stickystate.showHit() and read/write the properties
> with stickystate.lastImg and so on.


http://www.pixelmech.com/
http://www.crossandthrone.com/


Professor Rumford: 'But I still don't understand about hyperspace.' 
The Doctor: 'Well, who does?' 
K9: 'I do.' 
Doctor: 'Shut up, K9!' 





More information about the thelist mailing list