1. Create a single object by using the object constructor or the literal
Create an object using the literal method: var stut = {name: "Zhang San"};
Create objects using built-in constructors: var stu = new Object (); stu.name = "Zhang San"
2. Factory mode
The class could not be created before considering ES6, and the developer invented a function that encapsulates the details of creating an object in a particular interface, creating a good object within a function, and then returning the object
The function Createperson () can construct a person object that contains all the necessary information according to the accepted parameters, although the factory pattern solves the problem of creating multiple similar problems but does not solve the object recognition problem
3. Constructor mode
Primitive constructors like object and array are automatically present in the execution environment at run time, and custom constructors can be created to define the type properties and methods of custom objects
Compared to the Factory mode 1. Create object not shown 2. The property method is paid directly to the This object 3. No Return statement
4. Prototype mode
Each function we create has a prototype property, and prototype is the prototype object of the object instance created by invoking the constructor
(1) He omitted the process of passing initialization parameters for the constructor, and all instances would get the same property value by default, although this would be a certain inconvenience to some extent, but this is not the biggest problem, the biggest problem is determined by the nature of their sharing
(2) A property that contains a base property value hides the property in the prototype and then contains the value of the reference data type, which can cause problems
Several common ways to create JavaScript