Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #28044

Re: Declaring the same global variable multiple times

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From "Christoph M. Becker" <cmbecker69@arcor.de>
Newsgroups comp.lang.javascript
Subject Re: Declaring the same global variable multiple times
Date Mon, 08 Jun 2015 17:03:23 +0200
Organization solani.org
Lines 22
Message-ID <ml4arq$il7$1@solani.org> (permalink)
References <7kn8natinqhrjpa3luqivrlcbrkb2mule3@4ax.com> <ml2c7f$an8$1@dont-email.me> <tho9naln5nh9d8tugq0n0efpthccat9r10@4ax.com> <38a42$55753cb7$6def49d5$28976@nntpswitch.blueworldhosting.com> <global-20150608165604@ram.dialup.fu-berlin.de>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace solani.org 1433775802 19111 eJwNxckBwDAIA7CVaDlsxgkQ9h+h1Ueu8UTDwsN8fXMumUch1aJIcuQWEipaGK7ixkjTTrx/HxS8ELw= (8 Jun 2015 15:03:22 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Mon, 8 Jun 2015 15:03:22 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
X-User-ID eJwFwQkBwDAIA0BLYw1P5EAB/xJ6p8fErsPUoKuLnRRrRmHiB8s5OFr8mlJ6u1YS07E+zuwHJpIR3Q==
In-Reply-To <global-20150608165604@ram.dialup.fu-berlin.de>
Cancel-Lock sha1:zMywHHT0TAS9oacBLnswra/Kztw=
X-NNTP-Posting-Host eJwNx8EBgDAIA8CZCiTAOFrI/iPo/Q7Ow5tBMCBoK7GvDONj+09dt6uabuchYSZGpwXVs/0BHHoQrQ==
Xref csiph.com comp.lang.javascript:28044

Show key headers only | View raw


Stefan Ram wrote:

> Cezary Tomczyk <cezary.tomczyk@gmail.com> writes:
>> Instead of that
> 
>   (that = a global)
> 
>>                you may create singleton which can store your data in a 
>> property and add method to get/set values.
>> Example:
>> var example = {
>>     sharedVariable: undefined,
> 
>   And »example« is what? Not a global?

Basically, `example` is a global, but the namespace pattern helps to
*reduce* the number of globals.  To *avoid* globals, IIFEs or the module
pattern might be more appropriate.

-- 
Christoph M. Becker

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Declaring the same global variable multiple times "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2015-06-07 08:13 -0700
  Re: Declaring the same global variable multiple times Steven D'Aprano <steve@pearwood.info> - 2015-06-08 01:56 +1000
  Re: Declaring the same global variable multiple times Denis McMahon <denismfmcmahon@gmail.com> - 2015-06-07 21:14 +0000
    Re: Declaring the same global variable multiple times "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2015-06-07 17:33 -0700
      Re: Declaring the same global variable multiple times Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-06-08 08:56 +0200
        Re: Declaring the same global variable multiple times "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2015-06-08 07:28 -0700
        Re: Declaring the same global variable multiple times "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-06-08 17:03 +0200
        Re: Declaring the same global variable multiple times Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-06-08 19:09 +0200
  Re: Declaring the same global variable multiple times "Joey@still_Learning.invalid" <Joey@still_Learning.invalid> - 2015-06-07 14:23 -0700

csiph-web