Can I overwrite a constructor in javascript?

javascript

Solution

Just temporarily save the `prototype` object, and then replace the constructor function:

var proto = UserModel.prototype;
UserModel = function () { /* new implementation */ };
UserModel.prototype = proto;

Problem

I just learned that I can overwrite a method in a Javascript class, as shown below, but what about the actual constructor? If possible, how do I do it without instantiating the class? ``` var UserModel = (function() { var User; User = function() {}; // <- I want to overwrite this whilst keeping below methods User.prototype.isValid = function() {}; return User; })(); ```

Original source