Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #32653
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Associating this with that |
| Date | 2017-02-24 12:59 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <87shn34uei.fsf@bsb.me.uk> (permalink) |
| References | <EeSdnRDlAqBUWzLFnZ2dnUU7-VvNnZ2d@westnet.com.au> |
Andrew Poulos <ap_prog@hotmail.com> writes:
> If I have code like this:
Much better to post actual code.
> var Con = function(a) {
> this.blah = a;
> collect.push(this.blah);
> };
>
> var collect = [],
> foo = new Con(15),
> bar = new Con(52),
> bao = new Con(22),
> boo = new Con(54);
>
> How can I know which object the this values stored in "collect" refer
> to when within one of the objects?
I don't know what you mean. collect holds numbers. The code would work
the same if you write collect.push(a) instead of collect.push(this.blah).
> My problem is that change to a
> value in, say, foo.blah will change the values for all the other blahs
> as well as some other related properties.
Really? Can you post an example based on the code above? I don't see
how it can match your description.
> Should "collect" just store the various this values instead?
Impossible to say since I don't know what this code is supposed to do.
What's the problem you are solving?
--
Ben.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Associating this with that Andrew Poulos <ap_prog@hotmail.com> - 2017-02-24 16:38 +1100
Re: Associating this with that Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-24 12:59 +0000
Re: Associating this with that Andrew Poulos <ap_prog@hotmail.com> - 2017-02-25 16:33 +1100
Re: Associating this with that "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-02-24 08:10 -0800
csiph-web