For example, in Function's object it has Function.prototype.toString method. I would like to modify its logic with a new toString method like:
function foo() {}
foo.prototype.toString = function() {}
const newFoo = new foo();
Then if I want to keep the original foo.prototype.toString method and used in the new logic, how can I do that?
This is the example I want to use it in new logic:
function foo() {}
const originalToString = foo.prototype.toString;
foo.prototype.toString = function() {
return `new toString: ${this.originalToString()}`
}
const newFoo = new foo();