Created
September 11, 2012 00:58
-
-
Save tantaman/3695187 to your computer and use it in GitHub Desktop.
Replace and still call an existing method on some Javascript object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var someObject = { | |
method: function() { | |
console.log("Original method"); | |
} | |
} | |
var oldMethod = someObject.method; | |
someObject.method = function() { | |
oldMethod.apply(this, arguments); | |
console.log("Doing new stuff"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment