The 4-legged cat

JavaScript

var animal = {
	super: function() { console.log("animal");},
  test: function() { console.log("animal");}
};

function animalfn () {
	this.super = function() { console.log("animal");};
  this.test = function() { console.log("animal");};
}

var cat = Object.create(animal);
cat.test = function() { console.log("cat");};

var dog = Object.create(animal);
dog.test = function() { console.log("dog");};

var bird = Object.create(animalfn);

//Now the cat has 4 legs
cat.test();

dog.test();
bird.test();
bird.prototype.test();

/*
This is a solution to a problem posed in this article:

http://elsamman.com/?p=32

You can read more about it here:

http://stackoverflow.com/questions/3191103/javascript-object-create-inheriting-nested-properties
*/