Closed anthumchris closed 5 years ago
Relevant: https://github.com/tc39/proposal-private-fields/issues/94
Btw, what would you expect key
to be in that loop, and how would you want to use it?
Thanks @bergus! Yes, this looks like a duplicate and I'll close. And you make a great point: key
could not be used to access even if it were avail.
key
could not be used to access even if it were avail.
That is one thing that makes this proposal confusing. Is #foo
a key name? Or not? If it isn't, then is .#
an operator? 🤔
It is a name, but not of a property key, and unlike a property key (which can be reified as a string or a symbol) a private name has no first-class representation. This proposal adds no new operators.
Oh ok, good to know. ;)
Could we make private fields accessible for enumeration within an instance? Currently, only public fields are reflected. Given that we can explicitly access private fields within an instance, it would also be useful to enumerate on them too: