Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37258
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Object equals other object |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <Z4edne0EI5e3auPAnZ2dnUU7-dPNnZ2d@westnet.com.au> |
| Date | 2019-09-16 09:00 +0200 |
| Message-ID | <XnsAACC5BADA63FDeejj99@194.109.6.166> (permalink) |
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.
However, the SAME object can be assigned different names:
let a = { 'c': 1 };
let d = a;
console.log(a === d); // true
console.log(a.c, d.c) // 1 1
a.c = 2;
console.log(a === d); // true
console.log(a.c, d.c) // 2 2
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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