Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
__ryan__
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
12 ms
·
181.
▲
by
__ryan__
8y ago
Because the difference between `object.count` and `object.#count` is NOT purely syntactical. Information is needed at the call site to determine if it is a private field access compared to an object property access. This is because a priva
182.
▲
by
__ryan__
8y ago
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 a
183.
▲
by
__ryan__
8y ago
Not as far as the spec is concerned. They decided that private variables should be completely scoped to the class. "Having a private field named x must not prevent there from being a public field named x, so accessing a private field c
184.
▲
by
__ryan__
8y ago
The rationale for the "#" syntax is that it makes it clear that the field is NOT an object property. This is an important distinction because you can do this: class Example { #myVar = 100; getPrivateMyVar() {