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


Groups > comp.lang.javascript > #27848

Re: Identity of values in Javascript

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.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: Identity of values in Javascript
Date Sat, 23 May 2015 22:27:50 +0200
Organization solani.org
Lines 35
Message-ID <mjqnrq$her$1@solani.org> (permalink)
References <555f256b$0$12988$c3e8da3$5496439d@news.astraweb.com> <87r3q8h3yf.fsf@bsb.me.uk> <555f7d3b$0$13002$c3e8da3$5496439d@news.astraweb.com> <87d21sgpqy.fsf@bsb.me.uk>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace solani.org 1432412858 17883 eJwFwQkBwDAIA0BNQJN0chiPfwm9Q9BYOgQPFqtYt7kO0Bs/qzV1bnZ2MP1LTcBctjXe4gMbhRE2 (23 May 2015 20:27:38 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Sat, 23 May 2015 20:27:38 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
X-User-ID eJwFwYkRwDAIA7CV+GzO4zQk7D9CJSSd00WwsFj2+tvMWLlwLiNp/bXBFBo7AzemOM9WdX8HKRBI
In-Reply-To <87d21sgpqy.fsf@bsb.me.uk>
Cancel-Lock sha1:kjCaj5vL+GiiuKjMzGcpSj38w4Y=
X-NNTP-Posting-Host eJwFwQERADEIAzBLDGj5lzPg6l/CEgQPp5JgQpAQ3sy1C8MvKgZl6zpXWWvohpwTUZFl3wMXfBCc
Xref csiph.com comp.lang.javascript:27848

Show key headers only | View raw


Ben Bacarisse wrote:

> Steven D'Aprano <steve@pearwood.info> writes:
> 
>> On Sat, 23 May 2015 04:17 am, Ben Bacarisse wrote:
>> 
>>> Informally, I'd describe ECMAScript argument passing as call by 
>>> sharing (as in Python) because that's how it behaves.
>> 
>> That's what I expected, but I've found so many places claiming that
>> Javascript uses call by value for "simple types" and call by 
>> reference for "reference types" that I wanted to see for myself.
>> (By the way, I've seen similar confusion and abuse of terminology
>> in the Ruby, Python and Java camps too.)

Call-by-reference usually means that you can assign another value to the
variable passed as argument.  That is not possible in ECMAScript
conforming languages (at least to my knowledge).  Consider, for instance:

    var obj = {};
    function change(val) {
        val = 42;
    }
    change(obj);
    console.log(obj);

That is supposed to emit something like `Object {}`, but not `42`.

BTW: even though the ECMAScript specification distinguished primitive
values and objects, this distinction is not absolutely necessary when
using ECMAScript implementations.  Most of the time, one can regard
numbers, booleans, strings etc. simply as being *immutable* objects.

-- 
Christoph M. Becker

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


Thread

Identity of values in Javascript Steven D'Aprano <steve@pearwood.info> - 2015-05-22 22:47 +1000
  Re: Identity of values in Javascript Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-22 19:17 +0100
    Re: Identity of values in Javascript Steven D'Aprano <steve@pearwood.info> - 2015-05-23 05:02 +1000
      Re: Identity of values in Javascript Steven D'Aprano <steve@pearwood.info> - 2015-05-23 05:25 +1000
      Re: Identity of values in Javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-05-22 23:51 +0200
      Re: Identity of values in Javascript Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-23 00:24 +0100
        Re: Identity of values in Javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-23 09:35 +0200
          Re: Identity of values in Javascript Steven D'Aprano <steve@pearwood.info> - 2015-05-23 23:04 +1000
        Re: Identity of values in Javascript "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-23 22:27 +0200
          Re: Identity of values in Javascript Steven D'Aprano <steve@pearwood.info> - 2015-05-25 01:58 +1000
        Re: Identity of values in Javascript Steven D'Aprano <steve@pearwood.info> - 2015-05-25 02:12 +1000
          Re: Identity of values in Javascript Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-24 23:33 +0100
            Re: Identity of values in Javascript Steven D'Aprano <steve@pearwood.info> - 2015-05-25 21:47 +1000
              Re: Identity of values in Javascript Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-26 00:10 +0100
                Re: Identity of values in Javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-26 17:34 +0200
                Re: Identity of values in Javascript Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-26 17:03 +0100
                Re: Identity of values in Javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-26 18:31 +0200
                Re: Identity of values in Javascript Steven D'Aprano <steve@pearwood.info> - 2015-05-27 23:40 +1000
                Re: Identity of values in Javascript Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-05-27 23:21 -0300
                Re: Identity of values in Javascript "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2015-05-27 19:32 -0700
                Re: Identity of values in Javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-28 22:38 +0200
                Re: Identity of values in Javascript Scott Sauyet <scott.sauyet@gmail.com> - 2015-05-26 09:06 -0700
                Re: Identity of values in Javascript Steven D'Aprano <steve@pearwood.info> - 2015-05-27 23:02 +1000
    Re: Identity of values in Javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-23 00:02 +0200
    Re: Identity of values in Javascript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-23 09:19 +0200
  Re: Identity of values in Javascript Steven D'Aprano <steve@pearwood.info> - 2015-05-23 05:20 +1000

csiph-web