今天,突然有实力要搞一下new,搜了一下。
http://stackoverflow.com/questions/1646698/what-is-the-new-keyword-in-javascriptIt creates a new object. The type of this object, is simply object.
It sets this new object's internal, inaccessible, [[prototype]] property to be the constructor function's external, accessible, prototype object.
It executes the constructor function, using the newly created object whenever this is mentioned.
It returns the newly created object, unless the constructor function returns a non-primitive value. In this case, that non-primitive value will be returned.这句最经典。
It returns the newly created object, unless the constructor function returns a non-primitive value. In this case, that non-primitive value will be returned.