June 2016
Beginner to intermediate
292 pages
6h 8m
English
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 ...
Read now
Unlock full access