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


Groups > comp.lang.javascript > #24069

Re: Date false

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Date false
Date 2014-05-10 10:36 +0200
Organization PointedEars Software (PES)
Message-ID <9594146.3ms6Ipm6O6@PointedEars.de> (permalink)
References <1JidnUNwV7viyvHOnZ2dnUVZ_t6dnZ2d@westnet.com.au> <falsy-date-20140509065812@ram.dialup.fu-berlin.de> <lkjdnp$rfg$1@speranza.aioe.org> <ToBoolean-20140509231033@ram.dialup.fu-berlin.de>

Show all headers | View raw


Stefan Ram wrote:

>   Since the OP apparently had an object, I wondered whether an object
>   can be made falsy somehow. The following did not work:
> 
> if( { valueOf: function (){ return false; }})document.writeln( 'a' );
> 
>   . »Not work« means that it wrote »a«.
> 
>   In fact, »9.2 ToBoolean« says that any object always is converted
>   to true,

No, it says that any *value of the Object type* is converted to “true”.

>   so I really do not understand how in the OP's
> 
> if( d )do_something();
> 
>   it is possible that »do_something();« is not executed, when d is
>   either a string (that is not equal to »""«) or an object.

As the “typeof” operation (§11.4.3) resulted in "date" – neither "object" 
nor "function" – we must assume that the value is of an additional type for 
which the “ToBoolean” algorithm has been augmented in the used 
implementation, according to §2 “Conformance”.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not Cc: me. / Bitte keine Kopien per E-Mail.

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


Thread

Date false Andrew Poulos <ap_prog@hotmail.com> - 2014-05-09 14:18 +1000
  Re: Date false Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-09 10:46 +0200
  Re: Date false "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-05-09 10:58 +0200
  Re: Date false Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-09 11:01 +0200
  Re: Date false Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-05-09 17:27 -0300
    Re: Date false Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-05-09 17:32 -0300
    Re: Date false Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-05-10 10:36 +0200
  Re: Date false Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-05-09 18:05 -0300

csiph-web