Charlie Harvey


check it's type...(the fact I wrote this means it's not what you would guess)

js> var a = []+[]
js> typeof a
that's a little odd to me.
Back to my argument that a lot of this behavior is normal js> []+{} "[object Object]"

that is really misleading, remember when I said array plus something is merging strings? > ['hi']+{} 'hi[object Object]'

what your example has actually done is printed the string notation for an object and put an empty string in front of it. That's totally normal/expected behavior.

With this next one, it is odd but it is still expected behavior

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

this isn't that surprising because you are forgetting something really important, boolean + boolean will be coerced into an int to fit your strict need for addition.

js> true+true
js> false+true

Therefore if you compare the results it will not only equal the number 2 but also be a number itself!

js>true+true === 1+1

I hope this helps everyone understand these oddities that aren't specific to just javascript.