日期:2014-05-16  浏览次数:20397 次

终于搞明白new 这个家伙干什么的。
今天,突然有实力要搞一下new,搜了一下。
http://stackoverflow.com/questions/1646698/what-is-the-new-keyword-in-javascript



It 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.

------解决方案--------------------

------解决方案--------------------

------解决方案--------------------