travisennis/rhino — comment on commit 00a8caa54f33932d305ce9a066aae5d6790c5ee7
File:  line 0
By travisennis:

I've been doing a bit more research trying to understand what this behavior should be and discovered the following:

V8 (via Node)

>d8>var a = {};
>d8>a + ""
>'[object Object]'

SpiderMonkey:

>js>var a = {}
>js>a + ""
>"[object Object]"

Rhino:

>js>var a = {}
>js>a + ""
>[object Object]

This seems to be consistent across each of the shells and does seem to give some validation to Rhino's behavior with this change:

>js> var a = Object.create(null)
>js> a + ""
>[object Object]

Strangely enough all three shells display the following behavior:

>js> {} + ""
>0

although V8 formats it as '[object Object]0'. That maybe be one of the strange corner-cases of Javascript that I just haven't run across yet.