|
|
|
|
|
by tnzm
1755 days ago
|
|
I know they're not, that's why I'm objecting to them in principle (even though I use them and they're quite handy). JavaScript already has a solution - just put the private fields in the parent closure where they can't be accessed externally. In my example above, x is a private field, and the constructor function Foo can be asynchronous. The new semantics is a kludge around the supposedly "optional" class syntax sugar. Remember, once upon a time JS was supposed to be Scheme... |
|
Your approach can't translate the following code:
The proper solution is to use a non-enumerable property with an unnamed Symbol name, which is possible but cumbersome.