I am going through the book "JavaScript for the Ninja" and found the following text in the context of "How to mimic private variable in JavaScript via Object literal and classes"
The author show the example of implementing private variable via object literal:
And then mentioned the following:
JavaScript doesn’t have private object properties. Instead, we can mimic them through closures, by defining variables and specifying object methods that will close over those variables. Because with object literals and classes our getter and setter methods aren’t created within the same function scope as variables that we could use for private object properties, we can’t do this
Could someone help me in understand the highlighted text.
