Skip to content

Latest commit

 

History

History
78 lines (68 loc) · 888 Bytes

JavaScript.md

File metadata and controls

78 lines (68 loc) · 888 Bytes

JavaScript WAT?

We all love NaN!

> NaN === NaN
false

Array additions and subtractions!

> [] + []
""
> [] - []
0

Array + Object * headaches!

> [] + {}
"[object Object]"
> {} + {}
NaN

Undefined and null

> undefined == null
true

Floating point imprecision

> 0.1 + 0.7
0.7999999999999999

Weak typing + implicit conversions * headaches! Because we all love consistency.

> "5" - 3
2
> "5" + 3
"53"

String - String * Integer. WAT?

> "5" + + "5"
"55"

Marvelous!

> "foo" + + "foo"
"fooNaN"
> "5" + - "2"
"5-2"

Apparently it's ok?

> "5" + - + - - + - - + + - + - + - + - - - "-2"
"52"

Because fuck math!

> var x = 3;
> '5' + x - x
50