{}+{} incosistency

2016-04-13 Thread Vic99999
if "{}+{}" is a statement, than how can it return (or yield) a result? ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: {}+{} incosistency

2016-04-13 Thread Caitlin Potter
Okay, I was under the impression OP was asking about a more serious incompatibility in actual code (and not in the dev-tools console), crisis averted :x > On Apr 13, 2016, at 12:31 PM, ziyunfei <446240...@qq.com> wrote: > > If you see this then you will understand. >

?????? {}+{} incosistency

2016-04-13 Thread ziyunfei
If you see this then you will understand. https://chromium.googlesource.com/chromium/src/+/4fd348fdb9c0b3842829acdfb2b82c86dacd8e0a/third_party/WebKit/Source/devtools/front_end/sdk/ConsoleModel.js#215 On 4/13/16 12:08 PM, Boris Zbarsky wrote: > It sounds like all the actual JS engines involved

Re: {}+{} incosistency

2016-04-13 Thread Boris Zbarsky
On 4/13/16 12:08 PM, Boris Zbarsky wrote: It sounds like all the actual JS engines involved get all of this right; the only difference is whether evaluation in the browser's console happens in an expression context or in a statement context. And in particular, it seems like most browsers

Re: {}+{} incosistency

2016-04-13 Thread Boris Zbarsky
On 4/13/16 12:04 PM, Allen Wirfs-Brock wrote: The V8 result is correct In an expression context. It sounds like all the actual JS engines involved get all of this right; the only difference is whether evaluation in the browser's console happens in an expression context or in a statement

Re: {}+{} incosistency

2016-04-13 Thread Allen Wirfs-Brock
> On Apr 13, 2016, at 8:11 AM, Caitlin Potter wrote: > > The thing is, V8 is getting this right, at least in ecma262 6.0 and later. I > haven’t checked ES5 to see if this has changed ES6 refactored ToPrimitive but the semantics (except for the @@toPrimitive hook) did

Re?? {}+{} incosistency

2016-04-13 Thread ziyunfei
lol: https://bugzilla.mozilla.org/show_bug.cgi?id=1264308___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: {}+{} incosistency

2016-04-13 Thread Michał Wadas
I can confirm - ziyunfei is right. Chrome console treats {}+{} as ({}+{}). The first one should be parsed as "empty block, unary plus operator, empty object literal". ({}+{}) is parsed as "empty object literal, addition operator, empty object literal". ({}+{}) yields "[object Object][object

Re: {}+{} incosistency

2016-04-13 Thread Caitlin Potter
Well, I think you’re wrong here: OrdinaryToPrimitive: Step 5: `methodNames` is [ “valueOf”, “toString” ] • For each name in methodNames in List order, do • Let method be ? Get(O, name). << `Object.prototype.valueOf, Object.prototype.toString` • If

Re: {}+{} incosistency

2016-04-13 Thread Till Schneidereit
On Wed, Apr 13, 2016 at 4:32 PM, Caitlin Potter wrote: > My read of section 12.8.3.1 ( > 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

Re??{}+{} incosistency

2016-04-13 Thread ziyunfei
I guess you are confused by a Chrome DevTools feature https://bugs.chromium.org/p/chromium/issues/detail?id=499864___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: {}+{} incosistency

2016-04-13 Thread Caitlin Potter
This isn’t a devtools feature, this is at a lower level, and impacts regular code (eg https://jsfiddle.net/jtbtjkLb/ ) The thing is, V8 is getting this right, at least in ecma262 6.0 and later. I haven’t checked ES5 to see if this has changed > On Apr 13, 2016,

Re: {}+{} incosistency

2016-04-13 Thread Caitlin Potter
My read of section 12.8.3.1 (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

{}+{} incosistency

2016-04-13 Thread Michał Wadas
Short question - code {}+{} V8 result: "[object Object][object Object]" Safari, Firefox, Edge: NaN Which one is correct? ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss