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


Groups > comp.lang.javascript > #14191 > unrolled thread

Difference between == and ===?

Started byJason Kim <iamjsonkim@gmail.com>
First post2012-05-28 20:19 -0700
Last post2012-06-01 15:56 +0000
Articles 13 on this page of 53 — 16 participants

Back to article view | Back to comp.lang.javascript


Contents

  Difference between == and ===? Jason Kim <iamjsonkim@gmail.com> - 2012-05-28 20:19 -0700
    Re: Difference between == and ===? Jason Kim <iamjsonkim@gmail.com> - 2012-05-28 21:46 -0700
      Re: Difference between == and ===? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-05-29 08:20 +0300
        Re: Difference between == and ===? Jason Kim <iamjsonkim@gmail.com> - 2012-05-29 07:56 -0700
          Re: Difference between == and ===? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-05-29 19:15 +0300
            Re: Difference between == and ===? Jason Kim <iamjsonkim@gmail.com> - 2012-05-29 10:35 -0700
              Re: Difference between == and ===? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-05-29 21:52 +0300
              Re: Difference between == and ===? Gregor Kofler <usenet@gregorkofler.com> - 2012-05-29 21:34 +0200
              Re: Difference between == and ===? Dr J R Stockton <reply1222@merlyn.demon.co.uk.not.invalid> - 2012-05-30 19:53 +0100
                Re: Difference between == and ===? Scott Sauyet <scott.sauyet@gmail.com> - 2012-05-31 04:52 -0700
                  Re: Difference between == and ===? Dr J R Stockton <reply1222@merlyn.demon.co.uk.not.invalid> - 2012-06-01 21:41 +0100
      Re: Difference between == and ===? Gregor Kofler <usenet@gregorkofler.com> - 2012-05-29 09:34 +0200
        Re: Difference between == and ===? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-29 14:13 +0200
          Re: Difference between == and ===? Jason Kim <iamjsonkim@gmail.com> - 2012-05-29 08:08 -0700
            Re: Difference between == and ===? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-29 17:32 +0200
              Re: Difference between == and ===? Jason Kim <iamjsonkim@gmail.com> - 2012-05-29 08:50 -0700
            Re: Difference between == and ===? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-29 16:26 +0000
              Re: Difference between == and ===? Jason Kim <iamjsonkim@gmail.com> - 2012-05-29 10:36 -0700
                Re: Difference between == and ===? Scott Sauyet <scott.sauyet@gmail.com> - 2012-05-29 10:52 -0700
                Re: Difference between == and ===? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-29 21:50 +0000
                  Re: Difference between == and ===? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-05-30 07:46 +0300
                    Re: Difference between == and ===? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-30 07:48 +0000
                      Re: Difference between == and ===? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-05-30 11:08 +0300
                        Re: Difference between == and ===? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-05-30 14:36 +0000
                        Re: Difference between == and ===? John G Harris <john@nospam.demon.co.uk> - 2012-05-30 15:26 +0100
                          Re: Difference between == and ===? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-05-30 20:17 +0300
                            Re: Difference between == and ===? John G Harris <john@nospam.demon.co.uk> - 2012-06-01 14:54 +0100
                              Re: Difference between == and ===? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-01 13:09 -0700
                                Re: Difference between == and ===? Gene Wirchenko <genew@ocis.net> - 2012-06-01 13:49 -0700
                                  Re: Difference between == and ===? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-06-01 14:21 -0700
                                Re: Difference between == and ===? John G Harris <john@nospam.demon.co.uk> - 2012-06-03 11:41 +0100
                                  Re: Difference between == and ===? Dr J R Stockton <reply1223@merlyn.demon.co.uk.not.invalid> - 2012-06-04 20:02 +0100
                                    Re: Difference between == and ===? BGB <cr88192@hotmail.com> - 2012-06-05 10:06 -0500
                                      Re: Difference between == and ===? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-05 18:12 +0000
                                        Re: Difference between == and ===? BGB <cr88192@hotmail.com> - 2012-06-05 21:23 -0500
                                          Re: Difference between == and ===? Norman Peelman <npeelmandog@cfl.rr.com> - 2012-06-05 23:16 -0400
                                            Re: Difference between == and ===? "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-06-06 07:55 +0300
                                        Re: Difference between == and ===? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-06 08:27 +0200
                                          Re: Difference between == and ===? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-06 21:22 +0200
                                        Re: Difference between == and ===? Dr J R Stockton <reply1223@merlyn.demon.co.uk.not.invalid> - 2012-06-06 18:56 +0100
                                          Re: Difference between == and ===? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-07 07:12 +0000
                                            Re: Difference between == and ===? Dr J R Stockton <reply1223@merlyn.demon.co.uk.not.invalid> - 2012-06-08 20:11 +0100
                                              Re: Difference between == and ===? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-09 14:22 +0000
                                      Re: Difference between == and ===? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-06 08:28 +0200
                                        Re: Difference between == and ===? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-06-06 09:51 +0000
                                          Re: Difference between == and ===? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-06 21:22 +0200
                                        Re: Difference between == and ===? BGB <cr88192@hotmail.com> - 2012-06-06 08:35 -0500
                                          Re: Difference between == and ===? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-06-06 21:19 +0200
                    Re: Difference between == and ===? John G Harris <john@nospam.demon.co.uk> - 2012-05-30 15:07 +0100
    Re: Difference between == and ===? John G Harris <john@nospam.demon.co.uk> - 2012-05-30 15:44 +0100
    Re: Difference between == and ===? Stefan Weiss <krewecherl@gmail.com> - 2012-06-01 10:05 +0200
      Re: Difference between == and ===? Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2012-06-01 20:05 +1000
      Re: Difference between == and ===? "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-06-01 15:56 +0000

Page 3 of 3 — ← Prev page 1 2 [3]


#14382

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2012-06-07 07:12 +0000
Message-ID<XnsA06B5DB206DF3eejj99@194.109.133.133>
In reply to#14373
Dr J R Stockton wrote on 06 jun 2012 in comp.lang.javascript:

> In comp.lang.javascript message <XnsA069CD919A8F5eejj99@194.109.133.133>
> , Tue, 5 Jun 2012 18:12:32, Evertjan. <exxjxw.hannivoort@inter.nl.net>
> posted:
> 
>>
>>"null" means a variable is not filled
>>with an allowed type value.

Yes, I know "null" must be allowed then.

> But see ECMA 262 5.1 4.3.12.            // FF is 13.0

I don't see that.

In many a database system a field can be declared to have a certain type
AND independently can be allowed to be empty of any filling, called "null".

A weak-typed language like JS could do 
without the distinction null/undefined.

SQL needing 

"WHERE NOT isnull([myField]) AND [myField] <> ''",

tastes much stronger typed than JS 

myField != ''
 
>         // FF is 13.0

Why?

<https://www.google.com/search?q=value+of+ff> About 329,000,000 results

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#14413

FromDr J R Stockton <reply1223@merlyn.demon.co.uk.not.invalid>
Date2012-06-08 20:11 +0100
Message-ID<8G+AY5CS5k0PFwAh@invalid.uk.co.demon.merlyn.invalid>
In reply to#14382
In comp.lang.javascript message <XnsA06B5DB206DF3eejj99@194.109.133.133>
, Thu, 7 Jun 2012 07:12:38, Evertjan. <exxjxw.hannivoort@inter.nl.net>
posted:

>>         // FF is 13.0
>
>Why?

Because it is just over six weeks since FF 12.0 appeared on the standard
release channel.

-- 
 (c) John Stockton, nr London, UK.    ?@merlyn.demon.co.uk     Turnpike v6.05.
 Website  <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
 PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
 Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.

[toc] | [prev] | [next] | [standalone]


#14421

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2012-06-09 14:22 +0000
Message-ID<XnsA06DA689C71BCeejj99@194.109.133.133>
In reply to#14413
Dr J R Stockton wrote on 08 jun 2012 in comp.lang.javascript:

> In comp.lang.javascript message <XnsA06B5DB206DF3eejj99@194.109.133.133>
> , Thu, 7 Jun 2012 07:12:38, Evertjan. <exxjxw.hannivoort@inter.nl.net>
> posted:
> 
>>>         // FF is 13.0
>>
>>Why?
> 
> Because it is just over six weeks since FF 12.0 appeared on the standard
> release channel.

That channel seems not to to be released on my glassfiber subscription,
perhaps the sci-fi channel would do temporarily? 

My fox-hunting years being over, I will wait a while.


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#14350

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-06-06 08:28 +0200
Message-ID<3020416.iSlBG1ltW2@PointedEars.de>
In reply to#14339
BGB wrote:

> FWIW, I had generally interpreted it more like:
> "null" means "there is no object here";

That is correct.

> "undefined" means "this value is not valid".

No, `undefined' is a valid value.


PointedEars
-- 
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee

[toc] | [prev] | [next] | [standalone]


#14353

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2012-06-06 09:51 +0000
Message-ID<XnsA06A78B53E304eejj99@194.109.133.133>
In reply to#14350
Thomas 'PointedEars' Lahn wrote on 06 jun 2012 in comp.lang.javascript:

>> "undefined" means "this value is not valid".
> 
> No, `undefined' is a valid value.

I couldn't have said it better.

.... Oh wait, I did. 


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#14371

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-06-06 21:22 +0200
Message-ID<23915532.kI1Qhs5MBj@PointedEars.de>
In reply to#14353
Evertjan. wrote:

> Thomas 'PointedEars' Lahn wrote on 06 jun 2012 in comp.lang.javascript:
>>> "undefined" means "this value is not valid".
>> No, `undefined' is a valid value.
> 
> I couldn't have said it better.
> 
> .... Oh wait, I did.

No, you did not.  See my correction.


PointedEars
-- 
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
  -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)

[toc] | [prev] | [next] | [standalone]


#14357

FromBGB <cr88192@hotmail.com>
Date2012-06-06 08:35 -0500
Message-ID<jqnmfk$6tu$1@news.albasani.net>
In reply to#14350
On 6/6/2012 1:28 AM, Thomas 'PointedEars' Lahn wrote:
> BGB wrote:
>
>> FWIW, I had generally interpreted it more like:
>> "null" means "there is no object here";
>
> That is correct.
>
>> "undefined" means "this value is not valid".
>
> No, `undefined' is a valid value.
>

apparently people seemed to miss what I meant by "means", which is not 
the same as "is".

I never said that it couldn't be seen or used, as then what would be the 
point of referring to it? it is more a matter of the meaning given to it.

[toc] | [prev] | [next] | [standalone]


#14369

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-06-06 21:19 +0200
Message-ID<1596793.oMNUckLgyt@PointedEars.de>
In reply to#14357
BGB wrote:
^^^
Who?

> On 6/6/2012 1:28 AM, Thomas 'PointedEars' Lahn wrote:
>> BGB wrote:
>>> FWIW, I had generally interpreted it more like:
>>> "null" means "there is no object here";
>>
>> That is correct.
>>
>>> "undefined" means "this value is not valid".
>>
>> No, `undefined' is a valid value.
> 
> apparently people seemed to miss what I meant by "means", which is not
> the same as "is".

Apparently you need to improve on your precision of language and clarity of 
expression.  This newsgroup, like any other technical newsgroup, is the 
ideal place to do that.

> I never said that it couldn't be seen or used, as then what would be the
> point of referring to it? it is more a matter of the meaning given to it.

When discussing technical matters, it is very helpful to use unambiguous 
terminology that everyone can agree on.  For programming languages, that is 
the language and terminology employed by the language's specification.  In 
this case, the ECMAScript Language Specification (currently, its 5.1 
Edition).

The `undefined' value – the sole value of the primitive Undefined type – 
neither necessarily is nor means that a value is not valid.  `undefined' 
*is* a value *of* *itself*.  When a *property's* value *is* the `undefined' 
value it means what the person defining the property intended it to mean – 
if they intended it to mean anything in the first place.

For the `undefined' value is the result of read access from a property that 
does not exist:

  var foo = {bar: 42};
  var undef = foo.baz;

However, there can be properties that exist and have the `undefined' value:

  var foo = {bar: void 0};

(If the difference matters, if host objects are not involved and if 
backwards compatibility is unimportant, the `in' operator can be used to 
tell the two conditions apart:  'baz' in foo === false; 'bar' in foo === 
true.)

The `undefined' value is the initial value of variables (as identifiers need 
to be declared in order to be variable names).  While it is not necessary, 
some people prefer to separate variable declaration, which is why until the 
variable is explicitly initialized it has the initial `undefined' value.  
But that does _not_ mean that the variable's value or the variable itself is 
not *valid* in-between.  It would simply mean "not initialized* *then*.

  var x;

  /* later */
  x = 42;

The `undefined' value is the value of (named) parameters for which no 
argument was passed:

  function foo (bar)
  {
    /* undefined */
    bar
  }

  foo();

However, it is also the value of (named) parameters for which the 
`undefined' value has been passed as argument:

  function foo (bar)
  {
    /* undefined */
    bar
  }

  var baz;
  foo(void 0);
  foo(baz);

Bottom line: Your notion of validity does not apply here.


PointedEars
-- 
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
  -- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)

[toc] | [prev] | [next] | [standalone]


#14237

FromJohn G Harris <john@nospam.demon.co.uk>
Date2012-05-30 15:07 +0100
Message-ID<ptPzLyEvmixPFwp6@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD>
In reply to#14229
On Wed, 30 May 2012 at 07:46:36, in comp.lang.javascript, Jukka K.
Korpela wrote:

  <snip>
>The "strict equals operator" corresponds to the intuitive notion of
>equality (identity of values).

But note that when comparing two objects they are == or === only if they
are the same object. Two different objects with the same value are not
deemed to be equal. You have to write your own method if want to do that
kind of comparison :-(

  John
-- 
John Harris

[toc] | [prev] | [next] | [standalone]


#14239

FromJohn G Harris <john@nospam.demon.co.uk>
Date2012-05-30 15:44 +0100
Message-ID<EvZYr$I3IjxPFw8p@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD>
In reply to#14191
On Mon, 28 May 2012 at 20:19:04, in comp.lang.javascript, Jason Kim wrote:
>How are they different and how are they used?

  How different :
Read sections 11.9.3 and 11.9.6 of ECMA 262 to see the specifications of
== and ===.

You will see that when comparing two numbers or two strings they give exactly
the same result.

  How used :
If the two things being compared can be of different types then go back to
11.9.3 and 11.9.6 and decide which gives the answer you want in that piece of
code.

For ECMA 262 see :
  <http://www.ecma-international.org/publications/files/ECMA-ST/Ecma262.pdf>

  John
-- 
John Harris

[toc] | [prev] | [next] | [standalone]


#14263

FromStefan Weiss <krewecherl@gmail.com>
Date2012-06-01 10:05 +0200
Message-ID<jq9t4t$oog$1@news.albasani.net>
In reply to#14191
On 2012-05-29 05:19, Jason Kim wrote:
> How are they different and how are they used?

To paraphrase Orwell - "some values are more equal than others".

scnr,
stefan

[toc] | [prev] | [next] | [standalone]


#14264

FromRoss McKay <au.org.zeta.at.rosko@invalid.invalid>
Date2012-06-01 20:05 +1000
Message-ID<ju4hs71f74qq77slihdrd5elqdraimi7c0@4ax.com>
In reply to#14263
On Fri, 01 Jun 2012 10:05:49 +0200, Stefan Weiss wrote:

>To paraphrase Orwell - "some values are more equal than others".

+1 :)
-- 
Ross McKay, Toronto, NSW Australia
"You can't control what you can't measure" - Tom DeMarco

[toc] | [prev] | [next] | [standalone]


#14269

From"Evertjan." <exjxw.hannivoort@interxnl.net>
Date2012-06-01 15:56 +0000
Message-ID<XnsA065B68E6E188eejj99@194.109.133.133>
In reply to#14263
Stefan Weiss wrote on 01 jun 2012 in comp.lang.javascript:

> On 2012-05-29 05:19, Jason Kim wrote:
>> How are they different and how are they used?
> 
> To paraphrase Orwell - "some values are more equal than others".

Exactly so, [depending on the criteria].

Equality depends on the creteria measured.

If no criteria are allowed to be excluded, 
an object [not in the js sense] or an orwellian pig
can only be compared with itself to be true. 

====

Animalfarmic values depends on the view of the viewer,
allowing levels of equality:

"more equal than" should perhaps be cast as a js binary operator:

( 1 == 1 ) >eq ( 1 == "1" )

This leads to various levels of true, since both are true,
breaking the axioma that a boolena value can have ony two states,
a fact well known in quantum mechanics. 


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [standalone]


Page 3 of 3 — ← Prev page 1 2 [3]

Back to top | Article view | comp.lang.javascript


csiph-web