You’ve learned about JavaScript classes and objects in Chapter 3. Here we’re providing a quick refresher, with additional details as they relate to the features of Microsoft AJAX Library.
In JavaScript, classes are reference types that derive from JavaScript’s Object
. Classes can have four types of members: fields, properties, methods, and events.
Fields and properties have the same meaning as in C#. Public fields hold the state of an object of the class. Properties are mechanisms that offer getter and setter functions for retrieving and modifying field values, which is useful when additional code needs to run when setting or reading a field value. When a property is created to expose a field, the field’s value should only be accessed through that property. This restriction is by convention only; field values can be accessed directly, but the convention requires using the getter and setter methods.
Because we use conventions, the implementation will differ...