Hacker News new | ask | show | jobs
by conartist6 977 days 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/95f5be3488b2ae6c0dfd9a886...

1 comments

There are truly private properties available now.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...