firefox-devtools / devtools-core

:rocket: Packages for Firefox DevTools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FF Nightly console: Empty object literal evaluates to undefined, object with quoted key gives syntax error

marianoguerra opened this issue · comments

I'm writing an introduction to js using Firefox devtools and the basic examples force me to explain more than I should.

I'm trying to introduce the JSON subset first, so no undefined and all object keys quoted, the problem is that an empty object literal evaluates to undefined, I assume it thinks it's an empty scope (Chrome evaluates to an empty object).

Also, I can't enter object literals with quoted keys (works on Chrome).

Screenshot:

ff-bug

Let me know if I should report this somewhere else.

Thanks! This would probably be better in bugzilla (https://bugzilla.mozilla.org/enter_bug.cgi?product=DevTools), but we might already have a bug on file for this.

{} and {"key": 42} are blocks of code and not objects (not sure if that's what you meant by scope). You can wrap them in parenthesis to get the expected behavior.

A few years ago Chrome changed the behavior of their console to start automatically turning such blocks into objects. We should probably do the same, but I don't know if we already have a bug on file for this. @nchevobbe should know.

Yes, we do have Bug 972530 for this, where there is already some discussion .

x = {key: 42} should return the object as well.