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


Groups > comp.lang.javascript > #14369

Re: Difference between == and ===?

Message-ID <1596793.oMNUckLgyt@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2012-06-06 21:19 +0200
Subject Re: Difference between == and ===?
Newsgroups comp.lang.javascript
References (15 earlier) <JRUUbNIW9zyPFwG+@J.A830F0FF37FB96852AD08924D9443D28E23ED5CD> <PjNch1HDZQzPFw9$@invalid.uk.co.demon.merlyn.invalid> <jql7em$9d0$1@news.albasani.net> <3020416.iSlBG1ltW2@PointedEars.de> <jqnmfk$6tu$1@news.albasani.net>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


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)

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


Thread

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

csiph-web