Symbols as Semi-Private Property Keys
advantages of making object properties private, its drawbacks and use cases
We'll cover the following...
Creating truly private properties and operations is feasible, but it’s not an obvious task in JavaScript. If it was as obvious as in Java, blog posts like this, this, this, this, and many more wouldn’t have emerged.
Check out Exercise 2 to find out more about how to simulate private variables in JavaScript to decide whether it’s worth for you.
Even though Symbols do not make attributes private, they can be used as a notation for private properties. You can use symbols to separate the enumeration of public and private properties, and the notation also makes it clear.
Access this course and 1400+ top-rated courses and projects.