I try to declare private Symbol property in ES6+ class, below’s approach are all wrong.
class MyClass {
#[Symbol.for('my-symbol-prop1')] = 'my-symbol-prop1'; // SyntaxError
[#Symbol.for('my-symbol-prop1')] = 'my-symbol-prop1'; // SyntaxError
}
My question: Is there any way to declare a true private Symbol property, just using hash notation like #myPrivateSymbolfield
, don’t using WeakMap
or enclosure approach