The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Global – Whats wrong with using it? How to use script instead?

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #38809

    I was on #javascript and some feel very strongly against global objects. As an alternative, they suggest using a external script for global stuff. I was wondering:

    1) What is wrong with having a global object or variable? for instance: var foo = document.getElementById(“bar”); This is assuming foo will always reference this object through out the script to avoid confusion.

    2) How would I have an external script contain the global object and how do I make my javascript reference the object each time I need it(there are many times)?

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.