Transferred from: http://www.cnblogs.com/Jener/p/5920963.html
★ Overview:
Using object literals, or adding new members dynamically to an empty object, is the easiest way to create an object. However, in addition to these two commonly used object creation methods, JavaScript also provides other ways to create objects. ★ Create an object using the factory function we can write a function whose function is to create an object that can be called an object factory method. ★ Define Object "construct" function note point: object constructor letter capitalized; Use the This keyword to add members to an object; Use the new keyword to call an object constructor ★ object's constructor property creates an object using the object constructor. The constructor property of each object references this constructor, as shown by using the Object factory function to create the object, the constructor property of each object refers to object (), and the constructor constructor called in the normal way is actually a function. The difference is that when you call it, you must add a "new" keyword, and if you do not add the keyword, the call to it is considered a normal function call. Note that the normal call constructor here, in the output window.name, is the output with the current normal call function value. If you don't understand, look at the picture. The difference between an object constructor and an object factory Method 1. Object creation code not shown in the object constructor; 2. The properties and methods that the new object should have are added by the this reference; 3. There is no return statement in the object constructor; 4. Usually the first letter of the object constructor is set to uppercase, To distinguish common functions.
JS Object factory functions and constructors