I am never going to complain about Python again

Frank Millman frank at chagford.com
Thu Oct 10 04:23:10 EDT 2013


"Steven D'Aprano" <steve at pearwood.info> wrote in message 
news:52562ee3$0$2931$c3e8da3$76491128 at news.astraweb.com...
> Just came across this little Javascript gem:
>
> ",,," == Array((null,'cool',false,NaN,4));
>
> => evaluates as true
>
> http://wtfjs.com/2011/02/11/all-your-commas-are-belong-to-Array
>
> I swear, I am never going to complain about Python again.
>

I am sure you know this, but for the record, Javascript has two equality 
operators, '==' and '==='.

The double form attempts to coerce the left and right sides to the same 
type, the triple form does not.

'1' == 1 returns true

'1' === 1 returns false

The moment I discovered this, I changed all my operators from the double 
form to the triple form. Now I no longer have surprises of this nature.

Frank Millman






More information about the Python-list mailing list