Skip to content

Instantly share code, notes, and snippets.

@tantaman
Created September 11, 2012 00:58
Show Gist options
  • Save tantaman/3695187 to your computer and use it in GitHub Desktop.
Save tantaman/3695187 to your computer and use it in GitHub Desktop.
Replace and still call an existing method on some Javascript object
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