{}+{} incosistency

Caitlin Potter caitpotter88 at gmail.com
Wed Apr 13 16:40:01 UTC 2016


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 <446240525 at qq.com> wrote:
> 
> 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 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 evaluate console stuff in
> a statement context, but Chrome is somewhat inconsistent about it.  Some
> experimentation suggests the following is happening, for various input
> strings:
> 
> 1) "{}": expression context; claims to be an Object.
> 2) "   {}": expression context.
> 3) "var x = 1": statement context; defines a property named "x" on
>     the global.
> 4) "let x = 1": statement context; creates a binding for "x".
> 5) "function f() {}": statement context; defines a property named "f"
>     on the global.
> 
> I haven't experimented with more interesting whitespace preceding a '{'
> but it looks like the heuristic is to use expression context if the
> first non-whitespace character is '{' and to use statement context
> otherwise or something.
> 
> -Boris
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> _______________________________________________
> 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/10cc026e/attachment.sig>


More information about the es-discuss mailing list