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


Groups > comp.lang.javascript > #32653

Re: Associating this with that

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.javascript
Subject Re: Associating this with that
Date Fri, 24 Feb 2017 12:59:01 +0000
Organization A noiseless patient Spider
Lines 37
Message-ID <87shn34uei.fsf@bsb.me.uk> (permalink)
References <EeSdnRDlAqBUWzLFnZ2dnUU7-VvNnZ2d@westnet.com.au>
Mime-Version 1.0
Content-Type text/plain
Injection-Info mx02.eternal-september.org; posting-host="f0767632bf97c0ea6386726587ada61d"; logging-data="13291"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18N5fqxKtBB9J+NLzQy+/yoxmBhAntwh2A="
Cancel-Lock sha1:eSnQ+5CCiidBkU5a62CIrQQ/SHQ= sha1:DxH3vy+ijAxS6Nvhc5+9ovkZRtg=
X-BSB-Auth 1.c6114b5a047a0756dbcc.20170224125901GMT.87shn34uei.fsf@bsb.me.uk
Xref csiph.com comp.lang.javascript:32653

Show key headers only | View raw


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


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