Ciao, per quanto riguarda l'eredità delle "classi" in javascript ( un po' confusionario) volevo capire una cosa, in questo esempio:
eredita le proprietà sangue figli, pelle, zampe e zampe0.
Quello che vorrei ottenere è di ereditare solo alcune proprietà che mi interessano, ad esempio se creo un altra "classe" uccello mi eredita anche 4 zampe, e invece ne ha 2.
In che modo si può fare questo cioè ereditare solo alcune proprietà alle classi desiderate?
Codice PHP:
<html>
<body>
<script type="text/javascript">
function Mammifero() {
this.sangue = "caldo";
this.figli = "vivipari";
this.zampe = 4;
this.zampe0 = 2;
}
function Dog() {
this.nome = "bobby";
this.razza = "settler";
}
Dog.prototype=new Mammifero();
function Cat() {
this.nome = "micio";
this.razza = "siamese";
}
Cat.prototype=new Mammifero();
function Bird() {
this.nome = "tytty";
this.razza = "canarino";
}
Bird.prototype=new Mammifero();
var cane = new Mammifero();
var gatto = new Mammifero();
var uccello = new Mammifero();
var bobby = new Dog();
var micio = new Cat();
var tytty = new Bird();
</script>
</body>
</html>