In addition to calling the constructor using the new operator, we can also throw out the new operator and create the object with just a generic function, so that some preparatory work is performed and the object is a function of the return value. 、
function Her () { return { ' Jon ' };}
Then we call her () to generate the object:
var a =// Jon
Console.log (A.constructor);
function Object () {}
In fact, constructors can also return objects, except that the use of this value will vary.
function She () { this. Name = ' Jon '; return { ' NV ' }}varnew her (); she.name; // undefined; // ' NV '
In this case, the constructor does not return the This object that contains the property name, but instead returns the standalone object that contains the property sex. However, this is also true if the return value is an object, as a non-object, as usual.
You can understand how an object is created inside a constructor:
function Her () { // var this = {}; this. Name = ' Jon '; // return this;}
On JavaScript Objects (II)---functions that return objects