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


Groups > comp.lang.javascript > #37268

Re: Object equals other object

From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.javascript
Subject Re: Object equals other object
Date 2019-09-16 11:56 +0200
Message-ID <gu94ijFgnp6U2@mid.individual.net> (permalink)
References <Z4edne0EI5e3auPAnZ2dnUU7-dPNnZ2d@westnet.com.au> <XnsAACC5BADA63FDeejj99@194.109.6.166> <RMadnQGkRsK51eLAnZ2dnUU7-I3NnZ2d@westnet.com.au> <gu945rFgkqgU1@mid.individual.net> <197fb351-f6f8-4f0c-9abf-6470d376edf9@googlegroups.com>

Show all headers | View raw


On 16.09.19 11:54, Julio Di Egidio wrote:

> On Monday, 16 September 2019 11:49:52 UTC+2, Arno Welzel  wrote:
>> On 16.09.19 10:30, Andrew Poulos wrote:
>>
>>> On 16/09/2019 5:00 pm, Evertjan. wrote:
>>>> Andrew Poulos <ap_prog@hotmail.com> wrote on 16 Sep 2019 in
>>>> comp.lang.javascript:
>>>>
>>>>> If I have
>>>>>
>>>>> let a = { "c": 1 },
>>>>>       b = { "c": 1 };
>>>>>
>>>>> then
>>>>>
>>>>> console.log(a === b); // false.
>>>>>
>>>>> My question is, why was it decided that JavaScript is to return false
>>>>> even if the two objects have the same number of properties, all the
>>>>> properties are named the same, and all the properties values are
>>>>> identical?
>>>>
>>>> Two DIFFERENT objects can never "be" the same.
>>>
>>> Yes, but why can't two objects that have exactly the same properties and 
>>> corresponding property values be considered the same? If I JSON 
>>> stringify both of them then they magically become the same, so why not 
>>> before?
>>
>> Because "===" does not convert object properties to a value for comparison.
>>
>> "a === b" is only true if a and b are exactly same thing and not just
>> the same value after some conversion.
>>
>> If you only want to compare values, use "==".
> 
> Just try this: alert({}=={})

This is not what I talked about.

> Ah, the fucking hubris...

Not helpful as usual.


-- 
Arno Welzel
https://arnowelzel.de

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


Thread

Object equals other object Andrew Poulos <ap_prog@hotmail.com> - 2019-09-16 12:44 +1000
  Re: Object equals other object "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-09-16 09:00 +0200
    Re: Object equals other object Andrew Poulos <ap_prog@hotmail.com> - 2019-09-16 18:30 +1000
      Re: Object equals other object Julio Di Egidio <julio@diegidio.name> - 2019-09-16 02:01 -0700
        Re: Object equals other object Andrew Poulos <ap_prog@hotmail.com> - 2019-09-16 19:39 +1000
        Re: Object equals other object John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-16 18:29 +0100
      Re: Object equals other object John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-16 10:04 +0100
        Re: Object equals other object Julio Di Egidio <julio@diegidio.name> - 2019-09-16 02:21 -0700
          Re: Object equals other object John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-16 18:39 +0100
          Re: Object equals other object Arno Welzel <usenet@arnowelzel.de> - 2019-09-17 10:45 +0200
      Re: Object equals other object Arno Welzel <usenet@arnowelzel.de> - 2019-09-16 11:49 +0200
        Re: Object equals other object Julio Di Egidio <julio@diegidio.name> - 2019-09-16 02:54 -0700
          Re: Object equals other object Arno Welzel <usenet@arnowelzel.de> - 2019-09-16 11:56 +0200
            Re: Object equals other object Julio Di Egidio <julio@diegidio.name> - 2019-09-16 03:09 -0700
              Re: Object equals other object Arno Welzel <usenet@arnowelzel.de> - 2019-09-16 13:47 +0200
                Re: Object equals other object Jon Ribbens <jon+usenet@unequivocal.eu> - 2019-09-16 13:43 +0000
  Re: Object equals other object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-09-17 00:53 +0200
    Re: Object equals other object Jon Ribbens <jon+usenet@unequivocal.eu> - 2019-09-16 23:03 +0000
      Re: Object equals other object "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-09-17 16:16 +0200
        Re: Object equals other object Arno Welzel <usenet@arnowelzel.de> - 2019-09-17 16:57 +0200
      Re: Object equals other object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-09-17 16:58 +0200
        Re: Object equals other object Jon Ribbens <jon+usenet@unequivocal.eu> - 2019-09-17 16:31 +0000
        Re: Object equals other object Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-11-30 04:38 +0100
    Re: Object equals other object John G Harris <niam@jghnorth.org.uk.invalid> - 2019-09-17 18:46 +0100

csiph-web