d8> ([] + [])
d8> ([] + {})
[object Object]
d8> ({} + [])
[object Object]
d8> ({} + {})
[object Object][object Object]
So I believe this is merely erroneous behavior of the console, not a weirdness of JavaScript itself.I didn't mention any of this in the talk (it would've killed the flow ;). Instead, I glossed over it and interpreted the syntax as any sane programmer would.
I guess it's an amusing bit of sleight-of-hand, but using it to mock JavaScript seems, I don't know, tasteless. Doesn't it have enough problems without inventing more?
To clarify, I thought the first part of the talk was funny. Here's a weird bit of Ruby. Hah! Here's a weird bit of JavaScript. Hah! Here's some JavaScript to make you think it's weird in a way it actually isn't! Uh, okay? Just don't see what's funny about that, I guess.
Also, I'm on an old version of node, but my output matches jsc.
I think the actual video was a little misleading, [] + {} == the string "[object Object]" not an object. The square brackets are just part of the tostring method and are unrelated to the square brackets of arrays.
----- jsc ------
------ node.js ------