Insights Blog
-- Browse All Articles --
Physics Articles
Physics Tutorials
Physics Guides
Physics FAQ
Math Articles
Math Tutorials
Math Guides
Math FAQ
Education Articles
Education Guides
Bio/Chem Articles
Technology Guides
Computer Science Tutorials
Forums
Chemistry
Biology and Medical
Earth Sciences
Computer Science
Computing and Technology
DIY Projects
Trending
Featured Threads
Log in
Register
What's new
Search
Search
Search titles only
By:
Chemistry
Biology and Medical
Earth Sciences
Computer Science
Computing and Technology
DIY Projects
Menu
Log in
Register
Navigation
More options
Contact us
Close Menu
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Forums
Other Sciences
Programming and Computer Science
JS Variable Hygiene: Preventing Global Var Access
Reply to thread
Message
[QUOTE="Filip Larsen, post: 6861267, member: 237222"] You are reading some grand design into this that I am not talking about. The OP question was if there was a way to not have global variables, i.e. variables that needs to be defined in the global namespace with a specific name. My suggest was simply 1) insert common parts (e.g. the gta array) directly instead of using some kind of eval scheme (assuming here all data is known at build time), 2) put stuff into a function (even an anonymous self-calling one if needed) to avoid polluting the global namespace. This is a very common way to model modules. All that said, yes, I agree that a step up in design could be to not deliver POD (plain old data) but actually encapsulate this with a javascript class. Then the design moves to designing a good class with setters, getters, iterators, search, find, etc. [/QUOTE]
Insert quotes…
Post reply
Forums
Other Sciences
Programming and Computer Science
JS Variable Hygiene: Preventing Global Var Access
Back
Top