3 ms·
Private and readonly properties are 100% possible on classes, and you don't even need the newfangled private property syntax! You can roll it your own easily, a
by conartist6 3y ago
Private and readonly properties are 100% possible on classes, and you don't even need the newfangled private property syntax! You can roll it your own easily, and all you need is WeakMap. Unfortunately nobody seems to understand what weak maps are for...
Here's the example code: https://gist.github.com/conartist6/95f5be3488b2ae6c0dfd9a8867fe2330 https://gist.github.com/conartist6/95f5be3488b2ae6c0dfd9a886...
- moltar 3y agoThere are truly private properties available now. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...