WTFJS

The weirdest tech I've ever always used

 

@marcos_placona

marcos@twilio.com

Why aren't you talking about Dart?

Dart is cool...

... you just don't get it...

about 50 lines later in Dart...

JavaScript can be an odd (f|d)uck sometimes

William Shakespeare

2 things can be == && !=

 > x=[0]
=> [0]
 > x == x
=> true

good...

still good...

 > x==!x
=> true

still goo.. Wait what?

x is equals x...

Learning outcome...

... but also different

Math isn't a confirmed science

 > 1+2==3
=> true
 > 0.5+0.7==1.2
=> true

good...

you nailed it!

 > 0.1+0.2==0.3
=> false

wait a minute...

math is hard...

Learning outcome...

... and even JS doesn't get it

Booleans are misleading

 > true+true===2
=> true
 > true-true===0 
=> true

basic maths...

and it's consistent! I think true is === 1 right?

 > true===1
=> false

Doh!

Plus some other oddities...

 > typeof null
=> 'object'
> typeof NaN
=> 'number'

when null is not actually null

NaN (not a number) is in fact a number

NaN with an identity crisis

> NaN===NaN
=> false

true != true

> 'true'==true
=> false

round it up!

> 9999999999999999
=> 10000000000000000
/* nine quadrillion, nine hundred ninety-nine trillion, nine hundred ninety-nine billion, 
nine hundred ninety-nine million, nine hundred ninety-nine thousand, nine hundred ninety-nine */

>  ({}+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]

=> JS

Thanks

WTFJS - The weirdest tech I've always used

By Marcos Placona

WTFJS - The weirdest tech I've always used

  • 726