Your code wasn't working because you can't change the prototype of an already created object, or at least not via the prototype
property.
Two alternatives exist:
Use the internal
__proto__
property, but this is not recommended because it is a non-standard property.Use the
setPrototypeOf(Object, prototype)
function, this is recommended and will be standardized in ES6.
Or even better, use the code snippet taken from the documentation link on setPrototypeOf()
:
Object.setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
obj.__proto__ = proto;
return obj;
}