I. Classes and modules
1. The implementation of the class is based on the prototype inheritance mechanism.
Two. Classes and prototypes
Three. Classes and constructors
1. The constructor is used to initialize the newly created object.
2. Use new, so the constructor simply initializes the object state.
3. Building a constructor is defining the class, so the first letter is capitalized .
4.
Four. Identification of constructors and classes
Five. Constrctor Properties
1. The value of the constructor property is a function object
For example:
var F = function () {}; This is a function object;
var p = f.prototype; Prototype Object
var c = p.constructor; Functions associated with a prototype object
F = = C //true
2. The prototype can be referenced in reverse constrctor;
For example:
Rang.prototype = {
Constructor:rang;
METHOD1: ...
METHOD2: ...
}
Six. Defining class three Footwork
1. First define a constructor and initialize the instance properties of the new object;
2. Define an instance method for the prototype of the constructor;
3. Define class fields and class properties for the constructor.
For example:
function DefineClass (constructor,methods,statics) {
if (methods) extend (constructor.prototype,methods);
if (statics) extend (constructor,statics);
return constructor;
}
201506300917_ JavaScript authoritative Guide (sixth edition)-classes and modules, defining class three footwork, defining functions for simple classes (p200-210)