Skip to content

Instantly share code, notes, and snippets.

@jlatt
Created March 26, 2012 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlatt/2209453 to your computer and use it in GitHub Desktop.
Save jlatt/2209453 to your computer and use it in GitHub Desktop.
function alias(fname) {
return function() {
return this[fname].apply(this, arguments);
};
};
function Animal() {};
Animal.prototype.sound = null;
Animal.prototype.animalSound = function() {
return this.sound;
};
function Dog() {};
Dog.prototype = new Animal();
Dog.prototype.sound = 'bark';
Dog.protoype.bark = alias('animalSound');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment