I'm replacing (overriding, improving, adding functionality to) a method in the prototype of the Date
object. Here is a simplified version of what I've done:
Date.prototype._toString = Date.prototype.toString;
Date.prototype.toString = function(mask) {
if(mask == undefined){return this._toString();}
//snip
//...
//snip
return date_string;
}
As I don't want to lose the standard method, I'm assigning the original method to a temporal variable and calling it if appropriate.
Is there a way of doing this without polluting the Date.prototype
namespace?
What I'm asking is this same question, only in Javascript.