The problem:Ever try to add properties to a function's argument, only to discover that argument just won't take properties?
var y = new obj.constructor()What makes this so interesting is every object you create by this method you can add properties to.
The solutionWhy not re-initialize the original object in this manner?
obj = new obj.constructor(obj)This works!! By giving the constructor method (or function, as the case may be) the object itself as an argument, it will return an exact copy of the original object. We must declare the object using the new statement, however, to re-initialize the original object altogether. (Don't ask me why. It just works that way. It's more syntactically correct anyway.) Thus, the following produces the desired result: