Skip to content

Instantly share code, notes, and snippets.

@wkronemeijer
Last active December 26, 2015 01:39
Show Gist options
  • Save wkronemeijer/7072371 to your computer and use it in GitHub Desktop.
Save wkronemeijer/7072371 to your computer and use it in GitHub Desktop.
Replace function with a new function, whilst still calling the original function.
function augment(obj, function_name, new_function) {
var original = obj[function_name];
obj[function_name] = function () {
new_function.bind(this, original).apply(this, arguments);
original.bind(this).apply(this, arguments);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment