Object oriented
The most mainstream programming paradigm (JS does not enforce object-oriented) in the form of a noun encapsulation description
Class/constructor
The code that describes the object, and also the template that describes an object
This can be used inside the constructor relative to the normal function, and new initialization is required
function A () { this. a=1 } Create
Use new to create
var a=New A ();
After using the new command, its function passes through a ' wrapper ': first create an empty object, which is assigned to the This keyword inside the function as a context object. In other words, this refers to a newly generated empty object, and all operations against this will occur on this empty object.
A constructor is called a constructor, which means that the purpose of the function is to manipulate the context object (the This object) and "construct" it as needed. If the return statement of the constructor returns an object, the new command returns the object specified by the return statement, otherwise it returns the constructed context object regardless of the return statement.
js--Object-oriented