Funny Javascript

We all know that English is a funny language but our Javascript is too. Here are the proof for it.

Open the terminal and execute node to get into REPL of Node.js

$ node

Now we are into REPL mode of Node.js, lets play with javascript to see how funny it is

Fun 1

> 3=="3"

true

> 3==="3"

false

Fun 2

> "33" + 1

'331'

> "33" -1

32

Fun 3

> "foo" +1

'foo1'

> "foo" -1

NaN

Fun 4

> true +1

2

> (true +1) ==2

true

> (true + 1)===2

true

> (true + true)

2

> (true + true)==2

true

> (true + true)===2

true

Here it comes

> true === 1;

false

> true ==="1";

false

> true == "1";

true

Fun 5

> parseInt('05')

5

> parseInt('09')

0

> parseInt('08')

0

> parseInt('07')

7

> parseInt('10')

10

> parseInt('012')

10

> parseInt('010')

8

> parseInt('077')

63

Why so, refer parseInt.

Fun 6

> (0.1+0.2)===0.3

false

> (0.1+0.2)>0.3

true

> 0.1+ 0.2

0.30000000000000004

Fun 7

> Math.max();

-Infinity

> Math.min();

Infinity

> Math.min < Math.max();

false

If you have anything to add here related to Javascript, post it in the comment. I will update it here with your name.