Axel, here ... that chapter is really a tiny one and every dev should read that at least once if JS is, by accident, their programming language: http://webreflection.blogspot.com/2010/10/javascript-coercion-demystified.html
br On Sun, Jan 6, 2013 at 6:10 PM, Axel Rauschmayer <[email protected]> wrote: > Note that == does not respect truthiness or falsiness: >> >> > 2 == true >> false >> > 2 == false >> false >> >> > '2' == true >> false >> > '2' == false >> false > > > None of these (above) abstract comparison operations represents "truthy" > or "falsy" behaviour. > > 0 == false; > // true > 11.9.3.7 converts to 0==0 > > > "" == false; > // true > 11.9.3.7 converts to ""==0 > 11.9.3.5 converts to 0==0 > > > 1 == true; > // true > 11.9.3.7 converts to 1==1 > > > "" becomes +0 per 9.3.1 > +0 becomes false per 9.2 > true becomes 1 per 9.3 table 12 > > > The unary logical NOT ! also converts with ToBoolean. > > 2==true is just the number two compared with the Boolean true, which > aren't equal in value or type and have no criteria for conversion. > > > I am aware (2==true converts to 2==1). But I was surprised when I first > found out. The above was slightly off-topic, because I misunderstood what > trick Andrea was referring to. > > > -- > Dr. Axel Rauschmayer > [email protected] > > home: rauschma.de > twitter: twitter.com/rauschma > blog: 2ality.com > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

