So I currently have the following code snippet. I am trying to create a Cylon class, which contains a model property and a prototype attack() method. I am creating a HumanSkin class, which inherits from the Cylon, and also adds its own prototype infiltrate() method.
function Cylon(model){
this.model = model;
}
Cylon.prototype.attack = function(){
return("Destroy all humans!");
}
function HumanSkin(){}
HumanSkin.prototype = new Cylon();
HumanSkin.prototype.infiltrate = function(){
return("Infiltrate the colonies");
}
cylon = new Cylon("raider");
caprica = new HumanSkin(6);
My issue is this -- why is console.log(caprica.model); returning Undefined? How can I easily get full inheritance (preferably with encapsulation) in JS?