Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse 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> References: 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 Andrew Poulos 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.