The structure of an API class
First, let's define a few terms. According to Mozilla's object-oriented JavaScript documentation, JavaScript is really a classless language. However, class
syntax was added on top of the language, so in JavaScript, a class
is sort of like a template for an object. A class is technically an object as well. A class definition pre-defines the methods and properties of an object generated from the class. Most experienced JavaScript developers will be familiar with a similar concept: object prototypes.
An object therefore, in this context, is simply an instance of a class! These classes are only slightly different from the prototype constructors you're probably familiar with, and instances of these classes are generated in the same way as with prototypal notation: using the new
keyword.
var grIncident = new GlideRecord('incident');
A method is a function or subroutine that's declared as part of a class (and any objects that are instances of that class).
A constructor...