
02/04/2012, 14:47
|
 | | | Fecha de Ingreso: enero-2012 Ubicación: Coruña
Mensajes: 475
Antigüedad: 13 años Puntos: 30 | |
Respuesta: JS Poo - vincular clases con las herencias. Bueno , me he animado y te pongo un ejemplo de herencia simple:
var Animal = function(type){ //clase animal
this.type = type;
}
Animal.prototype.getType = function(){ // cramos el proptotimo de la clase animal
return this.type;
}
var Dog = function(options){
this.breed = options.breed;
} //creamos una clase para que sea posteriormente inferior a animales
Dog.prototype = new Animal('Dog'); // asignamos la clase dog como prototimo de "new animal" estamos inicializando un objeto, el cual tendra como clase "Dog" que heredará de animales todos los metodos y propiedades |