Javascript quirks

by trivektor

Inspired by this post I would like to compose a list of Javascript quirks for my self and anyone else interested. Here comes the bride…

(1, 2, 3) = 3

1 + + 1 = 2

1 + – + 1 = 0

1 – – 1 = 2

1 – – – 1 = 0

+ + + + 1 = 1

– – – 3 = -3

+[] = 0

2 + [] = “2”

2 + + [] = 2

1 + false = 1

1 + true = 2

a = 1; a+++1; alert(a) //2

1 + [1] = “11”

1 == [1] //true

Advertisements