News for hackers. Stuff that matters.
Re:V8 release v7.2 by __ryan__ on Tuesday December 18, 2018 @10:15AM (#18706980)
The difference is that when you type example.myVar = 400 you are setting a property names "myVar" on the object to 400. When you type example.#myVar you are trying to set example's private field to 400. The intentions are distinct and it is not costly to determine at the call site what you're trying to do.
Re:V8 release v7.2 by earthboundkid on Tuesday December 18, 2018 @02:51PM (#18709889)
What if I have private values I want to access programmatically? Ie. fields = ['#foo', '#baz', '#bar']; fields.forEach(field => { this[field] = frobnicate(field) }); ?
Re:V8 release v7.2 by __ryan__ on Tuesday December 18, 2018 @04:00PM (#18710520)
I don't know what the spec's solution for that would be, but what you've typed would not work. Specifically because when I say `this.#foo` it is not a property on the object named "#foo". It is just the syntax for looking up a private field referenced by the literal #foo.
Re:V8 release v7.2 by Klathmon on Tuesday December 18, 2018 @05:07PM (#18711037)
The spec's solution is to not solve that problem ;)

Dynamic property access isn't allowed for private fields, so it kind of side steps that whole issue.