No subject

Thu May 14 19:55:25 PDT 2009

On Fri, May 15, 2009 at 2:58 PM, Brendan Eich <brendan at> wrote:
> implicit conversions to boolean due to chained && and ||, we agreed to make
> ToBoolean(obj) = true for all Object-typed (ES1 term: any non-primitive)
> obj.

That makes

   (new Number(0))?true:false;             // gives true
   (new String(""))?true:false;               // gives true
   (new Boolean(false))?true:false;       // gives true,  !!!! @#

   strvar = new String("");  /* some code */ ; strvar == null
// gives false
   (new Date("1 JAN 2009"))==(new Date("1 JAN 2009"))         // gives false
   (new Number(123))==(new Number(123))        //gives  false
   (new String("xyz"))==(new String("xyz"))        //gives  false

It is weird...

Why cant we make objects for Number, String, Boolean, Date acts like
their native counter part?
That will be what an average web developer expecting.
And I dont think it will make existing web break.

We could categorize these objects to a kind which also include 'null'
and 'undefined' .......


More information about the es-discuss mailing list