Once we have found a satisfactory solution to control the visibility of an object's members, we have to face how public members can be accessed and which constraints we can set.
When we define public properties, we do not put any constraints on their accessibility. Consider the literal person definition:
var person = { name: "John", surname: "Smith"};
Public properties are readable and writable and they can be set to any value. The following assignments are perfectly legal:
var personName = person.name; person.name = "Mario"; person.surname = [1, 2, 3];
But for the meaning we want to give to the object, these assignments might not make sense or not be desirable. Assigning an array to a person's surname is definitively bizarre!
In general, it would be desirable to have more control over the way to access public properties in order to determine as precisely as possible the meaning of an object. For example...