Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #28044
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Declaring the same global variable multiple times |
| Date | 2015-06-08 17:03 +0200 |
| Organization | solani.org |
| 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> |
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
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