Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
Prototype of class's instances?

I'm trying to understand why the following code works the way it does.

I think it's contradictory that logging killerRabbit.prototype gives undefined while at the same time it seems to be equal to Rabbit.prototype.

Does it has an associated prototype but no actual prototype as a property?.

In that case, how do I access those prototypes properties?

class Rabbit {
  constructor(type) {
    this.type = type;
  }
  speak(line) {
    console.log(`The ${this.type} rabbit says '${line}'`);
  }
}
let killerRabbit = new Rabbit("killer");
console.log(Object.getPrototypeOf(killerRabbit)==Rabbit.prototype);//true
console.log(killerRabbit.prototype);//undefined
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want to access the prototype property on an instance, try this:

console.log(killerRabbit.__proto__);

And this property point to the prototype property of the based class.

console.log(killerRabbit.__proto__ === Rabbit.prototype); // true
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda