{}+{} incosistency

Caitlin Potter caitpotter88 at gmail.com
Wed Apr 13 14:32:29 UTC 2016

My read of section (https://tc39.github.io/ecma262/#sec-addition-operator-plus-runtime-semantics-evaluation),
is that V8 is getting this right.

ToPrimitive on `{}` will, by default, return “[object Object]” — We first call `Object.prototype.valueOf()`, which returns `this` (see Following this, we call `toString()`, and get “[object Object]”.

Subsequent steps of the algorithm just concatenate the two strings together. So it looks like the other vendors are getting this wrong?

> On Apr 13, 2016, at 10:20 AM, Michał Wadas <michalwadas at gmail.com> wrote:
> Short question - code
> {}+{}
> V8 result: "[object Object][object Object]"
> Safari, Firefox, Edge: NaN
> Which one is correct?
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160413/8175c883/attachment.sig>

More information about the es-discuss mailing list