Skip to content

Inspected objects’ symbol key properties are hidden by default #9709

@mightyiam

Description

@mightyiam
  • Version: v7.1.0
  • Platform: Linux shahar-desktop 4.8.0-27-generic docs: added a the #29-Ubuntu SMP Thu Oct 20 21:03:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: ?

I find it useful to be able to inspect the contents of an object by by looking at it in an interactive session. I'll call this the "debug representation". What is the correct term, please?

Now that we have symbols I'm experimenting with using them as object keys. I think it should reduce chance of accidental name collisions/overwrites, if done properly.

Thing is—while inspection of objects with "normal" keys is easy:

{ foo: undefined }
// { foo: undefined }

Inspection of objects with symbol keys is hard:

let obj = { [Symbol()]: undefined }

obj
// {}

While, obviously:

Object.getOwnPropertySymbols(obj)
// [ Symbol() ]

😢

I expect this:

obj
// { Symbol(): undefined }

It makes sense, doesn't it?

We already have this, so it makes sense to expect what I'm expecting, does’t it?

Symbol()
// Symbol()
Symbol('foo')
// Symbol(foo)

Chrome DevTools seems to do the right thing:
screenshot_2016-11-20_15-52-28

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionIssues that look for answers.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions