Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
¿Prototipo de instancias de clase?

Estoy tratando de entender por qué el siguiente código funciona de la manera que lo hace.

Creo que es contradictorio que el registro de killerRabbit.prototype dé undefined mientras que al mismo tiempo parece ser igual a Rabbit.prototype .

¿Tiene un prototipo asociado pero no un prototipo real como propiedad?

En ese caso, ¿cómo accedo a las propiedades de esos prototipos?

 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 answers
Answer question

0

Si desea acceder a la propiedad prototipo en una instancia, intente esto:

 console.log(killerRabbit.__proto__);

Y esta propiedad apunta a la propiedad prototype de la clase basada.

 console.log(killerRabbit.__proto__ === Rabbit.prototype); // true
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!