Skip to content

Instantly share code, notes, and snippets.

@miguel12345
Created December 1, 2013 07:50
Show Gist options
  • Save miguel12345/7729636 to your computer and use it in GitHub Desktop.
Save miguel12345/7729636 to your computer and use it in GitHub Desktop.
Method overloading
function addMethod(object,name,fn){
var old = object[name];
object[name] = function() {
if(fn.length == arguments.length){
return fn.apply(this,arguments);
}
else if(typeof old == "function"){
return old.apply(this,arguments);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment