Vanilla JS Prototypal Inheritence
by rpflorence
JavaScript
var Human = Object.create({
energy: 10,
breath: 'bad',
alertEnergy: function(){
alert(this.energy);
}
});
var Ninja = Object.create(Human);
Ninja.energy = 100;
// is there a way to redefine the energy for ninjas
// inside the create method or something else?
var tom = Object.create(Human);
var ryu = Object.create(Ninja)
tom.alertEnergy();
ryu.alertEnergy();