Redefining an Existing Method : prototype : Object Oriented JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Object Oriented » prototype »

 

Redefining an Existing Method













Function.prototype.toString = function () {
    return "Function code hidden";
};
function sayHi() {
    alert("hi");
}

alert(sayHi.toString());


Function.prototype.originalToString = Function.prototype.toString;

Function.prototype.toString = function () {
    if (this.originalToString().length > 100) {
        return "too long.";
    else {
        return this.originalToString();
    }
};







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Object Oriented
» prototype